QuickMongo
Quick Mongodb wrapper for beginners that provides key-value based interface.
Installing
$ npm install --save mongodb
$ npm install --save quickmongo
Documentation
https://quickmongo.js.org
Features
- Beginner friendly
- Strongly typed
- Asynchronous
- Dot notation support
- Key-Value like interface
- Easy to use
Example
const { Collection: MongoCollection, MongoClient } = require("mongodb");
const { Collection, Fields } = require("quickmongo");
const mongo = new MongoClient("mongodb://localhost/quickmongo");
const schema = new Fields.ObjectField({
difficulty: new Fields.StringField(),
items: new Fields.ArrayField(new Fields.StringField()),
balance: new Fields.NumberField()
});
mongo.connect()
.then(() => {
console.log("Connected to the database!");
doStuff();
});
async function doStuff() {
const mongoCollection = mongo.db().collection("JSON");
const db = new Collection(mongoCollection, schema);
await db.set("userInfo", { difficulty: "Easy", items: [], balance: 0 }).then(console.log);
await db.push("userInfo", "Sword", "items").then(console.log);
await db.add("userInfo", 500, "balance").then(console.log);
await db.push("userInfo", "Watch", "items").then(console.log);
await db.add("userInfo", 500, "balance").then(console.log);
await db.get("userInfo", "balance").then(console.log);
await db.get("userInfo", "items").then(console.log);
await db.pull("userInfo", "Sword", "items").then(console.log);
}
Discord Support
SnowflakeDev Community ❄️