Devis mongo client
A data storage plugin for Devisjs
This module supports the majority of necessary features for using your MongoDB database.
Install
We should install Devis and the plugin :
$ npm install --save devis$ npm install --save devis-mongo-client
Supported functions
-
Connect to the database :
- Syntax :
;- Example :
; -
Create a collection :
- Syntax :
; -
Drop a collection :
- Syntax :
; -
Find data :
- Syntax :
;type : one or many (default : many);
- Examples :
- Example 1 :
//close is true by default, but if you don't wanan close the connection you should give false as argument;- Example 2 :
;
-
Indexes :
- Create Index :
- Syntax :
type : ensureIndex or createIndex.; - check index if exist :
- Syntax :
; - get indexes of a given collection :
- Syntax :
; - Example :
- Create Index :
-
Insert data :
- Syntax :
;type : one or many.
- Example :
let data =Value: "1"Name: "foo" Acronym:"foo1"Value: "2"Name: "bar" Acronym:"bar1";; -
Delete data :
- Syntax :
;type : one or many.
- Example :
; -
Update data :
- Syntax :
;type : one or many.
- Example :
let queryOr=$or:Value: "1"Value:"2";let newData=$set: Name: "foobar";; -
Aggregate functions :
- Syntax :
;- Example :
let aggQuery ="$match": "date": "29.05.2017""$group":"_id": "Key": "$Key" "date": "$date""count": "$sum": 1;;
Example :
//Initialize a Devis instancelet devisMongoClient = //use the devis-mongo-client plugin let promise = { //connect to the database let promise = { devis; };promise