Constructor
new MapperMongoDb(options)
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | Queue configuration Properties
|
- Source:
- See:
Example
// Require the mapper class:
const MapperMongoDb = require('MapperMongoDb');
// Instanciate the mapper with default values:
const mapper = new MapperMongoDb();
// Connect the database:
yield mapper.connect();
// Perform tasks such as loading objects:
const user = mapper.getObject(_id, User);
Methods
close() → {MapperMongoDb}
Close the database
- Source:
Returns:
- The database mapper
- Type
- MapperMongoDb
connect() → {MapperMongoDb}
Connect the database
- Source:
Returns:
- The database mapper
- Type
- MapperMongoDb
deleteObject(obj) → {Object}
Remove an object from the mongoDb database.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object to delete from the database |
- Source:
Returns:
- Instance
- Type
- Object
getObject(_id, constructor) → {Object}
Load an object from the mongoDb database.
Parameters:
Name | Type | Description |
---|---|---|
_id |
String | ObjectId | Object _id to search for |
constructor |
Contructor | Constructor to use to instanciate the object |
- Source:
Returns:
- Instance
- Type
- Object
getObjectCollection() → {Object}
Retrieve the object collection.
- Source:
Returns:
- The collection for this object
- Type
- Object
getObjectCollectionName() → {String}
Retrieve the object collection name from the object given in parameter, the constructor or prototype.
- Source:
Returns:
- The collection name
- Type
- String
saveObject(obj) → {Object}
Save an object to the mongoDb database.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object to persist to the database |
- Source:
Returns:
- New instance of the object
- Type
- Object