Constructor
new Collection(name, optionsopt)
Constructor for a Collection
Parameters:
| Name |
Type |
Attributes |
Description |
name |
string
|
null
|
|
The name of the collection. If null, creates an unmanaged (unsynchronized) local collection. |
options |
object
|
<optional>
|
Properties
| Name |
Type |
Attributes |
Description |
transform |
function
|
<optional>
|
An optional transformation function.
Documents will be passed through this function before being returned from fetch or findOne,
and before being passed to callbacks of observe, map, forEach, allow, and deny.
Transforms are not applied for the callbacks of observeChanges or to cursors returned from publish functions. |
|
- Source:
- See:
-
Classes
- Collection
Methods
find(selector, optionsopt) → {Cursor}
Find the documents in a collection that match the selector.
If called in useTracker it automatically invokes a new Tracker.Computation
// TODO add reactive flag to options to disable reactivity for this call
// TODO evaluate if hint: { $natural } can be implemented for backward search
Parameters:
| Name |
Type |
Attributes |
Description |
selector |
string
|
object
|
|
A query describing the documents to find |
options |
object
|
<optional>
|
Properties
| Name |
Type |
Attributes |
Description |
sort |
object
|
<optional>
|
|
limit |
number
|
<optional>
|
|
skip |
number
|
<optional>
|
|
fields |
object
|
<optional>
|
|
|
- Source:
Returns:
-
Type
-
Cursor
findOne(selector, options) → {Cursor}
Parameters:
| Name |
Type |
Description |
selector |
|
|
options |
|
|
- Source:
Returns:
-
Type
-
Cursor
helpers(helpers)
Define helpers for documents. This is basically an implementation of
`dburles:mongo-collection-helpers`
Parameters:
| Name |
Type |
Description |
helpers |
object
|
dictionary of helper functions that become prototypes of the documents |
- Source:
- See:
-
insert(item, callbackopt)
Inserts a new document into the collection.
If this is a collection that exists on the server, then it also
calls the respective server side method
/collectionName/insert
Parameters:
| Name |
Type |
Attributes |
Description |
item |
object
|
|
the document to add to the collection |
callback |
function
|
<optional>
|
optional callback, called when complete with error or result |
- Source:
remove(id, callbackopt)
Remove a **single** document by a given id.
If it's not a local collection then the respective server
collection method endpoint /collectionName/remove is called.
Parameters:
| Name |
Type |
Attributes |
Description |
id |
string
|
MongoID.ObjectID
|
|
_id of the document to remove |
callback |
function
|
<optional>
|
optional callback, called when complete with error or result |
- Source:
update(id, modifier, optionsopt, callbackopt)
Update **a single** document by given id.
If this is a collection that exists on the server, then it also
calls the respective server side method
/collectionName/update
Parameters:
| Name |
Type |
Attributes |
Description |
id |
string
|
MongoID.ObjectID
|
|
id or ObjectID of the given document |
modifier |
object
|
|
the modifier, see the minimongo docs for supported modifiers |
options |
object
|
<optional>
|
Properties
| Name |
Type |
Attributes |
Description |
localOnly |
boolean
|
<optional>
|
force update call to server, even if this is a local collection |
|
callback |
function
|
<optional>
|
optional callback, called when complete with error or result |
- Source: