2.0.3 • Published 6 years ago

basicmongo v2.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

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

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago