A class represents a MongoDB collection in the client side, wrapped with RxJS Observables, so you can use it with your Angular 2 easier. The wrapper has the same API as Mongo.Collection, only the "find" method returns an ObservableCursor instead of regular Mongo.Cursor.
T is a generic type - should be used with the type of the objects inside the collection.
Kind: global class
Mongo.Collection.<T>BooleanBooleanMongo.CollectionMongo.DbObservable.<string>Observable.<Number>Observable.<Number>Observable.<{numberAffected, insertedId}>ObservableCursor.<T>anyObjectMongo.Selector | Mongo.ObjectID | stringObjectObjectCreates a new Mongo.Collection instance wrapped with Observable features.
| Param | Type | Description |
|---|---|---|
| nameOrExisting | String | Mongo.Collection |
The name of the collection. If null, creates an unmanaged (unsynchronized) local collection. If provided an instance of existing collection, will create a wrapper for the existing Mongo.Collection. |
| options | ConstructorOptions |
Creation options. |
Mongo.Collection.<T>Returns the Mongo.Collection object that wrapped with the MongoObservable.Collection.
Kind: instance property of Collection
Returns: Mongo.Collection.<T> - The Collection instance
BooleanAllow users to write directly to this collection from client code, subject to limitations you define.
Kind: instance method of Collection
BooleanOverride allow rules.
Kind: instance method of Collection
Mongo.CollectionReturns the Collection object corresponding to this collection from the npm mongodb driver module which is wrapped by Mongo.Collection.
Kind: instance method of Collection
Returns: Mongo.Collection - The Collection instance
See: rawCollection on Meteor documentation
Mongo.DbReturns the Db object corresponding to this collection's database connection from the npm mongodb driver module which is wrapped by Mongo.Collection.
Kind: instance method of Collection
Returns: Mongo.Db - The Db instance
See: rawDatabase on Meteor documentation
Observable.<string>Insert a document in the collection.
Kind: instance method of Collection
Returns: Observable.<string> - Observable which completes with the inserted ObjectId
See: insert on Meteor documentation
| Param | Type | Description |
|---|---|---|
| doc | T |
The document to insert. May not yet have an _id attribute, in which case Meteor will generate one for you. |
Observable.<Number>Remove documents from the collection.
Kind: instance method of Collection
Returns: Observable.<Number> - Observable which completes with the number of affected rows
See: remove on Meteor documentation
| Param | Type | Description |
|---|---|---|
| selector | MongoQuerySelector |
Specifies which documents to modify |
Observable.<Number>Modify one or more documents in the collection.
Kind: instance method of Collection
Returns: Observable.<Number> - Observable which completes with the number of affected rows
See: update on Meteor documentation
| Param | Type | Description |
|---|---|---|
| selector | MongoQuerySelector |
Specifies which documents to modify |
| modifier | Modifier |
Specifies how to modify the documents |
| options | MongoUpdateOptions |
Update options first argument and, if no error, the number of affected documents as the second |
Observable.<{numberAffected, insertedId}>Finds the first document that matches the selector, as ordered by sort and skip options.
Kind: instance method of Collection
Returns: Observable.<{numberAffected, insertedId}> - Observable which completes with an
Object that contain the keys numberAffected and insertedId.
See: upsert on Meteor documentation
| Param | Type | Description |
|---|---|---|
| selector | MongoQuerySelector |
Specifies which documents to modify |
| modifier | Modifier |
Specifies how to modify the documents |
| options | MongoUpsertOptions |
Upsert options first argument and, if no error, the number of affected documents as the second. |
ObservableCursor.<T>Method has the same notation as Mongo.Collection.find, only returns Observable.
Kind: instance method of Collection
Returns: ObservableCursor.<T> - RxJS Observable wrapped with Meteor features.
See: find on Meteor documentation
| Param | Type | Description |
|---|---|---|
| selector | MongoQuerySelector |
A query describing the documents to find |
| options | MongoQueryOptions |
Query options, such as sort, limit, etc. |
Example (Using Angular2 Component)
const MyCollection = MongoObservable.Collection("myCollection");
class MyComponent {
private myData: ObservableCursor<any>;
constructor() {
this.myData = MyCollection.find({}, {limit: 10});
}
}
anyFinds the first document that matches the selector, as ordered by sort and skip options.
Kind: instance method of Collection
Returns: any - The first object, or undefined in case of non-existing object.
See: findOne on Meteor documentation
| Param | Type | Description |
|---|---|---|
| selector | MongoQuerySelector |
A query describing the documents to find |
| options | MongoQueryOptions |
Query options, such as sort, limit, etc. |
ObjectAn options object for MongoDB queries.
Kind: inner typedef of Collection
Properties
| Name | Type | Description |
|---|---|---|
| sort | Object |
Sort order (default: natural order) |
| skip | Number |
Number of results to skip at the beginning |
| fields | Object |
Dictionary of fields to return or exclude. |
| reactive | Boolean |
(Client only) Default true; pass false to disable reactivity |
| transform | function |
Overrides transform on the Collection for this cursor. Pass null to disable transformation. |
Mongo.Selector | Mongo.ObjectID | stringA MongoDB query selector representation.
Kind: inner typedef of Collection
ObjectA MongoDB query options for upsert action
Kind: inner typedef of Collection
Properties
| Name | Type | Description |
|---|---|---|
| multi | Boolean |
True to modify all matching documents; false to only modify one of the matching documents (the default). |
ObjectA MongoDB query options for update action
Kind: inner typedef of Collection
Properties
| Name | Type | Description |
|---|---|---|
| multi | Boolean |
True to modify all matching documents; |
| upsert | Boolean |
True to use upsert logic. |