quick.mongodb
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Quick.MongoDB

Quick mongodb wrapper for beginners.

QuickMongo

Features

  • Beginner friendly
  • Easy to use
  • Very similar to quick.db
  • Dot notation support
  • Import & export support
  • Key value based
  • Simple
  • Asynchronous
  • Multiple model support

Quick Example

const { Database } = require("quick.mongodb");
const db = new Database("mongodb://localhost/quick.mongodb");

db.on("ready", () => {
    console.log("Database connected!");
});

db.set("foo", "bar");

db.get("foo").then(console.log);

Importing data from quick.db

const db = require("quick.db");
const { Database } = require("quick.mongodb");
const mongo = new Database("mongodb://localhost/quick.mongodb");

function importData() {
    const data = db.all();
    mongo.import(data).then(() => {
        console.log("Done!");
    });    
}

mongo.on("ready", () => importData());

Example

const { Database } = require("quick.mongodb");
const db = new Database("mongodb://localhost/quick.mongodb");

// Setting an object in the database:
db.set("userInfo", { difficulty: "Easy" }).then(console.log);
// -> { difficulty: 'Easy' }

db.push("userInfo.items", "Sword").then(console.log);
// -> { difficulty: 'Easy', items: ['Sword'] }

db.add("userInfo.balance", 500).then(console.log);
// -> { difficulty: 'Easy', items: ['Sword'], balance: 500 }

// Repeating previous examples:
db.push("userInfo.items", "Watch").then(console.log);
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 500 }

db.add("userInfo.balance", 500).then(console.log);
// -> { difficulty: 'Easy', items: ['Sword', 'Watch'], balance: 1000 }

// Fetching individual properties
db.get("userInfo.balance").then(console.log);
// -> 1000
db.get("userInfo.items").then(console.log);
// -> ['Sword', 'Watch']

Package Sidebar

Install

npm i quick.mongodb

Weekly Downloads

21

Version

1.0.1

License

MIT

Unpacked Size

40.6 kB

Total Files

12

Last publish

Collaborators

  • spikie