basicmongo

2.0.3 • Public • Published

WHAT'S NICE ABOUT THIS MODULES?

  1. Offer an easier way to access mongodb, no more callbacks after callbacks.
  2. In each instance commands will be run by sequnce, you don't have to worry about those "find" command run before "update" command situations anymore.

HOW TO USE?

Quick Start

    const BasicMongo = require('basicmongo');
    const mongo = BasicMongo.create(
        '%YOUR HOST%',
        %YOUR PORT%,
        '%YOUR DATABASE%',
        %DEBUG OR NOT%);

    mongo
        .run( (db, resolve, reject) => {
            db.collection('test')
                .find({})
                .toArray(
                    (err, result) => {
                        console.log(result);
                        resolve(result);
                    }
                )
        } )
        .get( (result, resolve) => {
            console.log(result);
            resolve();
        } );

Or You Can Use EasyMongo Methods

    mongo
        .collection('test')

        .find({})
        .get( (data, resolve) => {
            console.log(data);
            resolve();
        } )

        .insert({ title: 'test' })

        .find({})
        .get( (data, resolve) => {
            console.log(data);
            resolve();
        } )

        .remove({ title: 'test' })

        .find({})
        .get( (data, resolve) => {
            console.log(data);
            resolve();
        } );

Method List

Basic Methods

  • run (runCommandFunc)
    • runCommandFunc (db, resolve, reject)
  • get (getCommandFunc)
    • getCommandFunc (result, resolve, reject)

EasyMongo Methods

  • insert (docs, options)
  • remove (selector, options)
  • update (selector, doc, options)
    • default options = { upsert : true, multi : true }
  • find (query, options) // You should use get method to get result.
  • rename (newName, options)
  • aggregate (pipeline, options) // You should use get method to get result.

CONTACT ME

Email: Maplemx@gmail.com

Package Sidebar

Install

npm i basicmongo

Weekly Downloads

5

Version

2.0.3

License

ISC

Last publish

Collaborators

  • maplemx