Methods
(async, inner) closeDbConnection()
Closes DB connection if exists.
- Source:
(async, inner) collectionStats(database, collection)
Returns collection statistics
Parameters:
Name | Type | Description |
---|---|---|
database |
string | |
collection |
string |
- Source:
Returns:
object
(async, inner) connectMongoDb(urlopt) → {object}
Initiates connection with the database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string |
<optional> |
- Source:
Returns:
mongodb.MongoClient
- Type
- object
(inner) databaseConnection()
Returns MongoDB connection, if it was initiated before, otherwise returns null.
- Source:
Returns:
openDbConnection
(async, inner) distinctDatabase(database, collection, distinct, queryopt)
Returns an array of distinct values in a given collection.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
distinct |
string | field name | |
query |
object |
<optional> |
- Source:
Returns:
array
(async, inner) dropCollection(database, collection)
Drops the whole collection.
Parameters:
Name | Type | Description |
---|---|---|
database |
string | |
collection |
string |
- Source:
Returns:
object
(async, inner) findInDatabase(database, collection, query, projectionopt)
Returns array of documents from the DB based on the query and the projection.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
query |
object | ||
projection |
object |
<optional> |
- Source:
Returns:
array
(async, inner) findOneAndDeleteInDatabase(database, collection, query, projectionopt)
Deletes and returns a document based on query and projection
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
query |
object | ||
projection |
object |
<optional> |
- Source:
Returns:
object
(async, inner) findOneAndUpdateInDatabase(database, collection, query, update, optionsopt)
Updates document from the DB based on the query and update operators and returns it.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
query |
object | ||
update |
object | must contain only update operator expressions | |
options |
object |
<optional> |
{ projection: {document}, sort: {document}, maxTimeMS: {number}, upsert: {boolean}, returnNewDocument: {string} - 'before' / 'after', collation: {document}, arrayFilters: [ {filterdocument1}, ... ] } |
- Source:
Returns:
document
(async, inner) findOneInDatabase(database, collection, query, projectionopt)
Returns document from the DB based on the query and the projection.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
query |
object | ||
projection |
object |
<optional> |
- Source:
Returns:
document
(async, inner) initiateDB()
Initiates default db connection.
- Source:
Returns:
true
(async, inner) insertManyToDatabase(database, collection, values, optionsopt)
Inserts array of documents into the database.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
values |
array | ||
options |
object |
<optional> |
- Source:
Returns:
object
(async, inner) insertOneToDatabase(database, collection, value)
Inserts one document into the database, into a specific collection.
Parameters:
Name | Type | Description |
---|---|---|
database |
string | |
collection |
string | |
value |
object |
- Source:
Returns:
document
(async, inner) removeDocumentsFromCollection(database, collection, query)
Deletes many documents from the collection.
To remove all documents from a collection pass an empty object as a query.
Parameters:
Name | Type | Description |
---|---|---|
database |
string | |
collection |
string | |
query |
object |
- Source:
Returns:
object
(async, inner) updateInDatabase(database, collection, query, updateFilter)
Updates many documents in the collection
Parameters:
Name | Type | Description |
---|---|---|
database |
string | |
collection |
string | |
query |
object | |
updateFilter |
object |
- Source:
Returns:
object
(async, inner) updateOneInDatabase(database, collection, query, update, optionsopt)
Updates document from the DB based on the query and update operators.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
database |
string | ||
collection |
string | ||
query |
object | ||
update |
object | ||
options |
object |
<optional> |
- Source:
Returns:
object