QuickMongo
Quick Mongodb wrapper for beginners that provides key-value based interface.
Installing
$ npm install --save quickmongo
Documentation
https://quickmongo.js.org
Features
- Beginner friendly
- Asynchronous
- Dot notation support
- Key-Value like interface
- Easy to use
- TTL (temporary storage) supported
- Provides quick.db compatible API
- MongoDriver for quick.db
Example
QuickMongo
import { Database } from "quickmongo";
const db = new Database("mongodb://localhost:27017/quickmongo");
db.on("ready", () => {
console.log("Connected to the database");
doStuff();
});
await db.connect();
async function doStuff() {
await db.set("userInfo", { difficulty: "Easy" });
await db.push("userInfo.items", "Sword");
await db.add("userInfo.balance", 500);
await db.push("userInfo.items", "Watch");
await db.add("userInfo.balance", 500);
await db.get("userInfo.balance");
await db.get("userInfo.items");
await db.pull("userInfo.items", "Sword");
await db.set("foo", "bar", 60);
setTimeout(async () => {
await db.get("foo");
}, 60_000);
}
Usage with quick.db
const { QuickDB } = require("quick.db");
const { MongoDriver } = require("quickmongo");
const driver = new MongoDriver("mongodb://localhost/quickdb");
driver.connect().then(() => {
console.log(`Connected to the database!`);
init();
});
async function init() {
const db = new QuickDB({ driver });
console.log(await db.set("userInfo", { difficulty: "Easy" }));
console.log(await db.get("userInfo"));
console.log(await db.get("userInfo.difficulty"));
console.log(await db.push("userInfo.items", "Sword"));
console.log(await db.add("userInfo.balance", 500));
console.log(await db.push("userInfo.items", "Watch"));
console.log(await db.add("userInfo.balance", 500));
console.log(await db.get("userInfo.balance"));
console.log(await db.get("userInfo.items"));
await driver.close();
}
Created and maintained by Archaeopteryx1
Discord Support
CesiumLabs