1.1.0 • Published 6 years ago

mongoose-client v1.1.0

Weekly downloads
12
License
GPL-3.0
Repository
github
Last release
6 years ago

mongoose-client

A mongoose client to make mongo CRUD convenient.

Install

npm install mongoose-client

Usage

1. require mongoose-client

var mongooseClient = require("mongoose-client");

2. Modify config

You must modify the configuration to your owns. So you can do it like this:

   var mongooseClientInstance = new mongooseClient({
     DB_IP: "xxx",
     DB_PORT: "xxx",
     DB_NAME: "xxx",
     schema: {
       collection1: {
         key1: {type: String},
         key2: {type: String}
       },
       collection2: {
         key1: {type: String},
         key2: {type: JSON},
         key3: {type: Array}
       },
       ... 
     }
   });

3. Use it

// insert:
mongooseClientInstance.insert(collection,data,callback);

// remove:
mongooseClientInstance.remove(collection,removeCondition,callback);

// update:
mongooseClientInstance.update(collection,updateCondition,update,options,callback);

// find: (sortMode is optional and default as {}, it also can be any other field such as {_id: -1} indicate results sorted by _id descrease)
mongooseClientInstance.find(collection,findPattern,callback,sortMode);

// find batch:(findPatern can be regular expression)
 mongooseClientInstance.findBatch(collection,findPattern,callback,sortMode);

All callbacks return result as:
{
	success: true/false,
	data: xxx,              // if success is true
	msg: xxx		        // if success is false
}	
1.1.0

6 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago