Class: MongoService

vertx-mongo-js/mongo_service~ MongoService

new MongoService()

A Vert.x service used to interact with MongoDB server instances.
Source:

Methods

count(collection, query, resultHandler) → {MongoService}

Count matching documents in a collection.
Parameters:
Name Type Description
collection string the collection
query Object query used to match documents
resultHandler function will be provided with the number of matching documents
Source:
Returns:
Type
MongoService

createCollection(collectionName, resultHandler) → {MongoService}

Create a new collection
Parameters:
Name Type Description
collectionName string the name of the collection
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

dropCollection(collection, resultHandler) → {MongoService}

Drop a collection
Parameters:
Name Type Description
collection string the collection
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

find(collection, query, resultHandler) → {MongoService}

Find matching documents in the specified collection
Parameters:
Name Type Description
collection string the collection
query Object query used to match documents
resultHandler function will be provided with list of documents
Source:
Returns:
Type
MongoService

findOne(collection, query, fields, resultHandler) → {MongoService}

Find a single matching document in the specified collection
Parameters:
Name Type Description
collection string the collection
query Object the query used to match the document
fields Object the fields
resultHandler function will be provided with the document, if any
Source:
Returns:
Type
MongoService

findWithOptions(collection, query, options, resultHandler) → {MongoService}

Find matching documents in the specified collection, specifying options
Parameters:
Name Type Description
collection string the collection
query Object query used to match documents
options Object options to configure the find
resultHandler function will be provided with list of documents
Source:
Returns:
Type
MongoService

getCollections(resultHandler) → {MongoService}

Get a list of all collections in the database.
Parameters:
Name Type Description
resultHandler function will be called with a list of collections.
Source:
Returns:
Type
MongoService

insert(collection, document, resultHandler) → {MongoService}

Insert a document in the specified collection
Parameters:
Name Type Description
collection string the collection
document Object the document
resultHandler function result handler will be provided with the id if document didn't already have one
Source:
Returns:
Type
MongoService

insertWithOptions(collection, document, writeOption, resultHandler) → {MongoService}

Insert a document in the specified collection with the specified write option
Parameters:
Name Type Description
collection string the collection
document Object the document
writeOption Object the write option to use
resultHandler function result handler will be provided with the id if document didn't already have one
Source:
Returns:
Type
MongoService

remove(collection, query, resultHandler) → {MongoService}

Remove matching documents from a collection
Parameters:
Name Type Description
collection string the collection
query Object query used to match documents
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

removeOne(collection, query, resultHandler) → {MongoService}

Remove a single matching document from a collection
Parameters:
Name Type Description
collection string the collection
query Object query used to match document
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

removeOneWithOptions(collection, query, writeOption, resultHandler) → {MongoService}

Remove a single matching document from a collection with the specified write option
Parameters:
Name Type Description
collection string the collection
query Object query used to match document
writeOption Object the write option to use
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

removeWithOptions(collection, query, writeOption, resultHandler) → {MongoService}

Remove matching documents from a collection with the specified write option
Parameters:
Name Type Description
collection string the collection
query Object query used to match documents
writeOption Object the write option to use
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

replace(collection, query, replace, resultHandler) → {MongoService}

Replace matching documents in the specified collection
Parameters:
Name Type Description
collection string the collection
query Object query used to match the documents
replace Object all matching documents will be replaced with this
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

replaceWithOptions(collection, query, replace, options, resultHandler) → {MongoService}

Replace matching documents in the specified collection, specifying options
Parameters:
Name Type Description
collection string the collection
query Object query used to match the documents
replace Object all matching documents will be replaced with this
options Object options to configure the replace
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

runCommand(command, resultHandler) → {MongoService}

Run an arbitrary MongoDB command.
Parameters:
Name Type Description
command Object the command
resultHandler function will be called with the result.
Source:
Returns:
Type
MongoService

save(collection, document, resultHandler) → {MongoService}

Save a document in the specified collection
Parameters:
Name Type Description
collection string the collection
document Object the document
resultHandler function result handler will be provided with the id if document didn't already have one
Source:
Returns:
Type
MongoService

saveWithOptions(collection, document, writeOption, resultHandler) → {MongoService}

Save a document in the specified collection with the specified write option
Parameters:
Name Type Description
collection string the collection
document Object the document
writeOption Object the write option to use
resultHandler function result handler will be provided with the id if document didn't already have one
Source:
Returns:
Type
MongoService

start()

Start the service
Source:

stop()

Stop the service
Source:

update(collection, query, update, resultHandler) → {MongoService}

Update matching documents in the specified collection
Parameters:
Name Type Description
collection string the collection
query Object query used to match the documents
update Object used to describe how the documents will be updated
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService

updateWithOptions(collection, query, update, options, resultHandler) → {MongoService}

Update matching documents in the specified collection, specifying options
Parameters:
Name Type Description
collection string the collection
query Object query used to match the documents
update Object used to describe how the documents will be updated
options Object options to configure the update
resultHandler function will be called when complete
Source:
Returns:
Type
MongoService