1.0.10 • Published 4 years ago
@thepuzzlemaker/dbpmstore-mongo v1.0.10
DBPMStore MongoDB Driver
A MongoDB driver for DBPMStore. Requires the mongodb
NodeJS package during runtime (if using the MongoDB driver), and during compile (if compiling from source).
Example Code:
import {DBPMStorageMongo} from "dbpmstore/drivers/mongo";
const storage = new DBPMStorageMongo({ connectionString: "some connection string", dbName: "db", writeTolerance: 3, collectionName: "collection"}, "document");
const doStuff = async () => {
try {
if (await storage.connect()) {
await storage.write("key", "value");
console.log(await storage.get("key")) // Console: "value"
await storage.disconnect();
} else {
console.error("Could not connect to the database!");
}
} catch (err) {
console.error(`Error: ${err.stack.trimLeft()}`);
process.exit(1);
}
};
doStuff();