Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quickmongo

Package Overview
Dependencies
Maintainers
5
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quickmongo

Quick Mongodb wrapper for beginners that provides key-value based interface.

  • 4.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by19.5%
Maintainers
5
Weekly downloads
 
Created
Source

QuickMongo

Quick Mongodb wrapper for beginners that provides key-value based interface.

Installing

$ npm install --save mongodb # required
$ 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);
    // -> { difficulty: 'Easy', items: [], balance: 0 }

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

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

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

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

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

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

Discord Support

SnowflakeDev Community ❄️

Keywords

FAQs

Package last updated on 01 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc