Skip to content

Commit

Permalink
Merge pull request #1 from EastolfiWebDev/aggregation
Browse files Browse the repository at this point in the history
Aggregation branch merged
  • Loading branch information
eastolfi committed Aug 4, 2016
2 parents 9f9eb8c + 8578900 commit 251e010
Show file tree
Hide file tree
Showing 24 changed files with 2,456 additions and 189 deletions.
11 changes: 7 additions & 4 deletions Gruntfile.js
Expand Up @@ -39,6 +39,7 @@ module.exports = function(grunt) {
"lib/Selector.js": "src/Selector.js",
"lib/Cursor.js": "src/Cursor.js",
"lib/Collection.js": "src/Collection.js",
"lib/Aggregation.js": "src/Aggregation.js",
"lib/MongoPortable.js": "src/MongoPortable.js"
}
}
Expand All @@ -48,14 +49,15 @@ module.exports = function(grunt) {
all: {
src: ['test/1_ObjectId.js', 'test/2_Selector.js',
'test/3_Cursor.js', 'test/4_Collection.js',
'test/5_MongoPortable.js', 'test/6_Coverage.js']
'test/5_Aggregation.js', 'test/6_MongoPortable.js',
'test/7_Coverage.js']
}
},

jsdoc : {
dist : {
src: ['src/MongoPortable.js', 'src/Collection.js', 'src/Cursor.js',
'src/Selector.js', 'src/ObjectId.js'],
src: ['src/MongoPortable.js', 'src/Aggregation.js', 'src/Collection.js',
'src/Cursor.js', 'src/Selector.js', 'src/ObjectId.js'],
options: {
destination: 'doc',
config: 'jsdoc.conf.json'
Expand All @@ -65,12 +67,13 @@ module.exports = function(grunt) {

jsdoc2md: {
fullDoc: {
src: ['src/MongoPortable.js', 'src/Collection.js', 'src/Cursor.js'],
src: ['src/MongoPortable.js', 'src/Aggregation.js', 'src/Collection.js', 'src/Cursor.js'],
dest: 'api/documentation.md'
},
apiDoc: {
files: [
{ src: 'src/MongoPortable.js', dest: 'api/MongoPortable.md' },
{ src: 'src/Aggregation.js', dest: 'api/Aggregation.md' },
{ src: 'src/Collection.js', dest: 'api/Collection.md' },
{ src: 'src/Cursor.js', dest: 'api/Cursor.md' }
]
Expand Down
Empty file added api/Aggregation.md
Empty file.
17 changes: 16 additions & 1 deletion api/Collection.md
Expand Up @@ -17,6 +17,7 @@ Collection class that maps a MongoDB-like collection
* [.destroy()](#Collection+destroy)
* [.drop([options], [callback])](#Collection+drop) ⇒ <code>Object</code>
* [.save(doc, [callback])](#Collection+save) ⇒ <code>Object</code>
* [.aggregate(pipeline, [options])](#Collection+aggregate) ⇒ <code>Array</code> &#124; <code>Cursor</code>

<a name="new_Collection_new"></a>

Expand Down Expand Up @@ -62,7 +63,7 @@ Finds all matching documents
| [options.skip] | <code>Number</code> | | Number of documents to be skipped |
| [options.limit] | <code>Number</code> | | Max number of documents to display |
| [options.fields] | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | | Same as "fields" parameter (if both passed, "options.fields" will be ignored) |
| [options.forceFetch] | <code>Boolean</code> | <code>false</code> | If set to'"true" returns't"e;array of documents already fetched |
| [options.forceFetch] | <code>Boolean</code> | <code>false</code> | If set to'"true" returns the array of documents already fetched |
| [callback] | <code>function</code> | <code></code> | Callback function to be called at the end with the results |

<a name="Collection+findOne"></a>
Expand Down Expand Up @@ -161,3 +162,17 @@ Insert or update a document. If the document has an "_id" is an update (with ups
| [options.writeConcern] | <code>Object</code> | <code></code> | An object expressing the write concern |
| [callback] | <code>function</code> | <code></code> | Callback function to be called at the end with the results |

<a name="Collection+aggregate"></a>

### collection.aggregate(pipeline, [options]) ⇒ <code>Array</code> &#124; <code>Cursor</code>
Calculates aggregate values for the data in a collection

**Kind**: instance method of <code>[Collection](#Collection)</code>
**Returns**: <code>Array</code> &#124; <code>Cursor</code> - If "options.forceFetch" set to true returns the array of documents, otherwise returns a cursor

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| pipeline | <code>Array</code> | | A sequence of data aggregation operations or stages |
| [options] | <code>Object</code> | | Additional options |
| [options.forceFetch] | <code>Boolean</code> | <code>false</code> | If set to'"true" returns the array of documents already fetched |

26 changes: 23 additions & 3 deletions api/Cursor.md
Expand Up @@ -7,7 +7,8 @@ Cursor class that maps a MongoDB-like cursor
**Since**: 0.0.1

* [Cursor](#Cursor)
* [new Cursor(db, collection, [selection], [fields], [options])](#new_Cursor_new)
* [new Cursor(db, documents, [selection], [fields], [options])](#new_Cursor_new)
* [.fetch_mode](#Cursor+fetch_mode)
* [.rewind()](#Cursor+rewind)
* [.forEach([callback])](#Cursor+forEach)
* [.map([callback])](#Cursor+map) ⇒ <code>Array</code>
Expand All @@ -18,6 +19,7 @@ Cursor class that maps a MongoDB-like cursor
* [.fetchOne()](#Cursor+fetchOne) ⇒ <code>Object</code>
* [.count()](#Cursor+count) ⇒ <code>Number</code>
* [.sort(spec)](#Cursor+sort) ⇒ <code>[Cursor](#Cursor)</code>
* [.sort(spec)](#Cursor+sort) ⇒ <code>[Cursor](#Cursor)</code>
* [.skip(skip)](#Cursor+skip) ⇒ <code>[Cursor](#Cursor)</code>
* [.limit(limit)](#Cursor+limit) ⇒ <code>[Cursor](#Cursor)</code>
* [.batchSize()](#Cursor+batchSize)
Expand All @@ -44,19 +46,25 @@ Cursor class that maps a MongoDB-like cursor

<a name="new_Cursor_new"></a>

### new Cursor(db, collection, [selection], [fields], [options])
### new Cursor(db, documents, [selection], [fields], [options])
Cursor


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| db | <code>MongoPortable</code> | | Additional options |
| collection | <code>Collection</code> | | The collection instance |
| documents | <code>Array</code> | | The list of documents |
| [selection] | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | <code>{}</code> | The selection for matching documents |
| [fields] | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | <code>{}</code> | The fields of the document to show |
| [options] | <code>Object</code> | | Database object |
| [options.pkFactory] | <code>Object</code> | <code></code> | Object overriding the basic "ObjectId" primary key generation. |

<a name="Cursor+fetch_mode"></a>

### cursor.fetch_mode
ADD IDX

**Kind**: instance property of <code>[Cursor](#Cursor)</code>
<a name="Cursor+rewind"></a>

### cursor.rewind()
Expand Down Expand Up @@ -128,6 +136,18 @@ Obtains the total of documents of the cursor
**Returns**: <code>Number</code> - The total of documents in the cursor
<a name="Cursor+sort"></a>

### cursor.sort(spec) ⇒ <code>[Cursor](#Cursor)</code>
Set the sorting of the cursor

**Kind**: instance method of <code>[Cursor](#Cursor)</code>
**Returns**: <code>[Cursor](#Cursor)</code> - This instance so it can be chained with other methods

| Param | Type | Description |
| --- | --- | --- |
| spec | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | The sorting specification |

<a name="Cursor+sort"></a>

### cursor.sort(spec) ⇒ <code>[Cursor](#Cursor)</code>
Applies a sorting on the cursor

Expand Down
43 changes: 39 additions & 4 deletions api/documentation.md
Expand Up @@ -439,6 +439,7 @@ Collection class that maps a MongoDB-like collection
* [.destroy()](#Collection+destroy)
* [.drop([options], [callback])](#Collection+drop) ⇒ <code>Object</code>
* [.save(doc, [callback])](#Collection+save) ⇒ <code>Object</code>
* [.aggregate(pipeline, [options])](#Collection+aggregate) ⇒ <code>Array</code> &#124; <code>[Cursor](#Cursor)</code>

<a name="new_Collection_new"></a>

Expand Down Expand Up @@ -484,7 +485,7 @@ Finds all matching documents
| [options.skip] | <code>Number</code> | | Number of documents to be skipped |
| [options.limit] | <code>Number</code> | | Max number of documents to display |
| [options.fields] | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | | Same as "fields" parameter (if both passed, "options.fields" will be ignored) |
| [options.forceFetch] | <code>Boolean</code> | <code>false</code> | If set to'"true" returns't"e;array of documents already fetched |
| [options.forceFetch] | <code>Boolean</code> | <code>false</code> | If set to'"true" returns the array of documents already fetched |
| [callback] | <code>function</code> | <code></code> | Callback function to be called at the end with the results |

<a name="Collection+findOne"></a>
Expand Down Expand Up @@ -583,6 +584,20 @@ Insert or update a document. If the document has an "_id" is an update (with ups
| [options.writeConcern] | <code>Object</code> | <code></code> | An object expressing the write concern |
| [callback] | <code>function</code> | <code></code> | Callback function to be called at the end with the results |

<a name="Collection+aggregate"></a>

### collection.aggregate(pipeline, [options]) ⇒ <code>Array</code> &#124; <code>[Cursor](#Cursor)</code>
Calculates aggregate values for the data in a collection

**Kind**: instance method of <code>[Collection](#Collection)</code>
**Returns**: <code>Array</code> &#124; <code>[Cursor](#Cursor)</code> - If "options.forceFetch" set to true returns the array of documents, otherwise returns a cursor

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| pipeline | <code>Array</code> | | A sequence of data aggregation operations or stages |
| [options] | <code>Object</code> | | Additional options |
| [options.forceFetch] | <code>Boolean</code> | <code>false</code> | If set to'"true" returns the array of documents already fetched |

<a name="Cursor"></a>

## Cursor
Expand All @@ -592,7 +607,8 @@ Cursor class that maps a MongoDB-like cursor
**Since**: 0.0.1

* [Cursor](#Cursor)
* [new Cursor(db, collection, [selection], [fields], [options])](#new_Cursor_new)
* [new Cursor(db, documents, [selection], [fields], [options])](#new_Cursor_new)
* [.fetch_mode](#Cursor+fetch_mode)
* [.rewind()](#Cursor+rewind)
* [.forEach([callback])](#Cursor+forEach)
* [.map([callback])](#Cursor+map) ⇒ <code>Array</code>
Expand All @@ -603,6 +619,7 @@ Cursor class that maps a MongoDB-like cursor
* [.fetchOne()](#Cursor+fetchOne) ⇒ <code>Object</code>
* [.count()](#Cursor+count) ⇒ <code>Number</code>
* [.sort(spec)](#Cursor+sort) ⇒ <code>[Cursor](#Cursor)</code>
* [.sort(spec)](#Cursor+sort) ⇒ <code>[Cursor](#Cursor)</code>
* [.skip(skip)](#Cursor+skip) ⇒ <code>[Cursor](#Cursor)</code>
* [.limit(limit)](#Cursor+limit) ⇒ <code>[Cursor](#Cursor)</code>
* [.batchSize()](#Cursor+batchSize)
Expand All @@ -629,19 +646,25 @@ Cursor class that maps a MongoDB-like cursor

<a name="new_Cursor_new"></a>

### new Cursor(db, collection, [selection], [fields], [options])
### new Cursor(db, documents, [selection], [fields], [options])
Cursor


| Param | Type | Default | Description |
| --- | --- | --- | --- |
| db | <code>[MongoPortable](#MongoPortable)</code> | | Additional options |
| collection | <code>[Collection](#Collection)</code> | | The collection instance |
| documents | <code>Array</code> | | The list of documents |
| [selection] | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | <code>{}</code> | The selection for matching documents |
| [fields] | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | <code>{}</code> | The fields of the document to show |
| [options] | <code>Object</code> | | Database object |
| [options.pkFactory] | <code>Object</code> | <code></code> | Object overriding the basic "ObjectId" primary key generation. |

<a name="Cursor+fetch_mode"></a>

### cursor.fetch_mode
ADD IDX

**Kind**: instance property of <code>[Cursor](#Cursor)</code>
<a name="Cursor+rewind"></a>

### cursor.rewind()
Expand Down Expand Up @@ -713,6 +736,18 @@ Obtains the total of documents of the cursor
**Returns**: <code>Number</code> - The total of documents in the cursor
<a name="Cursor+sort"></a>

### cursor.sort(spec) ⇒ <code>[Cursor](#Cursor)</code>
Set the sorting of the cursor

**Kind**: instance method of <code>[Cursor](#Cursor)</code>
**Returns**: <code>[Cursor](#Cursor)</code> - This instance so it can be chained with other methods

| Param | Type | Description |
| --- | --- | --- |
| spec | <code>Object</code> &#124; <code>Array</code> &#124; <code>String</code> | The sorting specification |

<a name="Cursor+sort"></a>

### cursor.sort(spec) ⇒ <code>[Cursor](#Cursor)</code>
Applies a sorting on the cursor

Expand Down

0 comments on commit 251e010

Please sign in to comment.