Modules
- BinaryParserBuffer
BinaryParserBuffer
- Cursor
Cursor
- MongoPortable
MongoPortable
- ObjectId
ObjectId
Classes
- Collection
Collection class that maps a MongoDB-like collection
BinaryParserBuffer
BinaryParserBuffer
Since: 0.0.1
Author: Eduardo Astolfi eastolfi91@gmail.com
License: MIT Licensed
Copyright: 2016 Eduardo Astolfi <eastolfi91@gmail.com>
Cursor
Cursor
Since: 0.0.1
Author: Eduardo Astolfi eduardo.astolfi91@gmail.com
License: MIT Licensed
Copyright: 2016 Eduardo Astolfi <eduardo.astolfi91@gmail.com>
MongoPortable
MongoPortable
Since: 0.0.1
Param | Type | Description |
---|---|---|
databaseName | string |
Name of the database. |
ObjectId
ObjectId
Since: 0.0.1
Author: Eduardo Astolfi eastolfi91@gmail.com
License: MIT Licensed
Copyright: 2016 Eduardo Astolfi <eastolfi91@gmail.com>
Param | Type | Description |
---|---|---|
id | string | number |
Can be a 24 byte hex string, a 12 byte binary string or a Number. |
Collection
Collection class that maps a MongoDB-like collection
Kind: global class
Since: 0.0.1
Author: Eduardo Astolfi eastolfi91@gmail.com
License: MIT Licensed
Copyright: 2016 Eduardo Astolfi <eastolfi91@gmail.com>
- Collection
- new Collection()
- [.insert(doc, [options], [callback])](#Collection+insert) ⇒
Promise.<Object>
- [.bulkInsert(docs, [options], [callback])](#Collection+bulkInsert) ⇒
Promise.<Array.<Object>>
- [.find([selection], [fields], [options], [callback])](#Collection+find) ⇒
Promise.<(Array.<Object>|Cursor)>
- [.findOne([selection], [fields], [options], [callback])](#Collection+findOne) ⇒
Promise.<Object>
- [.update([selection], [update], [options], [callback])](#Collection+update) ⇒
Promise.<Object>
- [.remove([selection], [options], [callback])](#Collection+remove) ⇒
Promise.<Array.<Obejct>>
- .delete()
- .destroy()
- [.drop([options], [callback])](#Collection+drop) ⇒
Promise.<Array.<Object>>
- .save(doc, [callback]) ⇒
Promise.<Object>
- .aggregate(pipeline, [options]) ⇒
Array
|Cursor
new Collection()
Collection
collection.insert(doc, [options], [callback]) ⇒ Promise.<Object>
Inserts a document into the collection
Kind: instance method of Collection
Returns: Promise.<Object>
- Returns a promise with the inserted document
Param | Type | Default | Description |
---|---|---|---|
doc | Object |
Document to be inserted | |
[options] | Object |
Additional options | |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.bulkInsert(docs, [options], [callback]) ⇒ Promise.<Array.<Object>>
Inserts several documents into the collection
Kind: instance method of Collection
Returns: Promise.<Array.<Object>>
- Returns a promise with the inserted documents
Param | Type | Default | Description |
---|---|---|---|
docs | Array |
Documents to be inserted | |
[options] | Object |
Additional options | |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.find([selection], [fields], [options], [callback]) ⇒ Promise.<(Array.<Object>|Cursor)>
Finds all matching documents
Kind: instance method of Collection
Returns: Promise.<(Array.<Object>|Cursor)>
- Returns a promise with the documents (or cursor if "options.forceFetch" set to true)
Param | Type | Default | Description |
---|---|---|---|
[selection] | Object | Array | String |
{} |
The selection for matching documents |
[fields] | Object | Array | String |
{} |
The fields of the document to show |
[options] | Object |
Additional options | |
[options.skip] | Number |
Number of documents to be skipped | |
[options.limit] | Number |
Max number of documents to display | |
[options.fields] | Object | Array | String |
Same as "fields" parameter (if both passed, "options.fields" will be ignored) | |
[options.doNotFetch] | Boolean |
false |
If set to'"true" returns the cursor not fetched |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.findOne([selection], [fields], [options], [callback]) ⇒ Promise.<Object>
Finds the first matching document
Kind: instance method of Collection
Returns: Promise.<Object>
- Returns a promise with the first matching document of the collection
Param | Type | Default | Description |
---|---|---|---|
[selection] | Object | Array | String |
{} |
The selection for matching documents |
[fields] | Object | Array | String |
{} |
The fields of the document to show |
[options] | Object |
Additional options | |
[options.skip] | Number |
Number of documents to be skipped | |
[options.limit] | Number |
Max number of documents to display | |
[options.fields] | Object | Array | String |
Same as "fields" parameter (if both passed, "options.fields" will be ignored) | |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.update([selection], [update], [options], [callback]) ⇒ Promise.<Object>
Updates one or many documents
Kind: instance method of Collection
Returns: Promise.<Object>
- Returns a promise with the update/insert (if upsert=true) information
Param | Type | Default | Description |
---|---|---|---|
[selection] | Object | Array | String |
{} |
The selection for matching documents |
[update] | Object |
{} |
The update operation |
[options] | Object |
Additional options | |
[options.updateAsMongo] | Number |
true |
By default: If the [update] object contains update operator modifiers, such as those using the "$set" modifier, then:
|
[options.override] | Number |
false |
Replaces the whole document (only apllies when [updateAsMongo=false]) |
[options.upsert] | Number |
false |
Creates a new document when no document matches the query criteria |
[options.multi] | Number |
false |
Updates multiple documents that meet the criteria |
[options.writeConcern] | Object |
|
An object expressing the write concern |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.remove([selection], [options], [callback]) ⇒ Promise.<Array.<Obejct>>
Removes one or many documents
Kind: instance method of Collection
Returns: Promise.<Array.<Obejct>>
- Promise with the deleted documents
Param | Type | Default | Description |
---|---|---|---|
[selection] | Object | Array | String |
{} |
The selection for matching documents |
[options] | Object |
Additional options | |
[options.justOne] | Number |
false |
Deletes the first occurrence of the selection |
[options.writeConcern] | Object |
|
An object expressing the write concern |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.delete()
Alias for remove
Kind: instance method of Collection
collection.destroy()
Alias for remove
Kind: instance method of Collection
collection.drop([options], [callback]) ⇒ Promise.<Array.<Object>>
Drops a collection
Kind: instance method of Collection
Returns: Promise.<Array.<Object>>
- Promise with the deleted documents
Param | Type | Default | Description |
---|---|---|---|
[options] | Object |
Additional options | |
[options.dropIndexes] | Number |
false |
True if we want to drop the indexes too |
[options.writeConcern] | Object |
|
An object expressing the write concern |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.save(doc, [callback]) ⇒ Promise.<Object>
Insert or update a document. If the document has an "_id" is an update (with upsert), if not is an insert.
Kind: instance method of Collection
Returns: Promise.<Object>
- Returns a promise with the inserted document or the update information
Param | Type | Default | Description |
---|---|---|---|
doc | Object |
Document to be inserted/updated | |
[options.dropIndexes] | Number |
false |
True if we want to drop the indexes too |
[options.writeConcern] | Object |
|
An object expressing the write concern |
[callback] | function |
|
Callback function to be called at the end with the results |
collection.aggregate(pipeline, [options]) ⇒ Array
| Cursor
Calculates aggregate values for the data in a collection
Kind: instance method of Collection
Returns: Array
| Cursor
- If "options.forceFetch" set to true returns the array of documents, otherwise returns a cursor
Param | Type | Default | Description |
---|---|---|---|
pipeline | Array |
A sequence of data aggregation operations or stages | |
[options] | Object |
Additional options | |
[options.forceFetch] | Boolean |
false |
If set to'"true" returns the array of documents already fetched |