trait Collection extends Object
Mongo Collection
- Annotations
- @RawJSType() @native()
- See also
http://mongodb.github.io/node-mongodb-native/2.1/api/index.html
- Alphabetic
- By Inheritance
- Collection
- Object
- Any
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
aggregate[A <: Any](pipeline: Array[_ <: Any], options: |[AggregationOptions, RawOptions] = js.native): AggregationCursor[A]
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
- pipeline
Array containing all the aggregation framework commands for the execution.
aggregate(pipeline, options, callback)
Example: -
def
aggregate[A <: Any](pipeline: Array[_ <: Any], callback: MongoCallback1[Array[A]]): Unit
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
- pipeline
Array containing all the aggregation framework commands for the execution.
- callback
The command result callback
aggregate(pipeline, options, callback)
Example: -
def
aggregate[A <: Any](pipeline: Array[_ <: Any], options: AggregationOptions, callback: MongoCallback1[Array[A]]): Unit
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
Execute an aggregation framework pipeline against the collection, needs MongoDB >= 2.2
- pipeline
Array containing all the aggregation framework commands for the execution.
- options
Optional settings.
- callback
The command result callback
aggregate(pipeline, options, callback)
Example: -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bulkWrite(operations: Array[Any], options: RawOptions = js.native): Promise[BulkWriteOpResultObject]
Perform a bulkWrite operation without a fluent API
Perform a bulkWrite operation without a fluent API
- operations
Bulk operations to perform.
- options
Optional settings.
bulkWrite(operations, options, callback)
Example: -
def
bulkWrite[A <: Any](operations: Array[A], callback: MongoCallback1[BulkWriteOpResultObject]): Unit
Perform a bulkWrite operation without a fluent API
Perform a bulkWrite operation without a fluent API
- operations
Bulk operations to perform.
- callback
The command result callback
bulkWrite(operations, options, callback)
Example: -
def
bulkWrite[A <: Any](operations: Array[A], options: RawOptions, callback: MongoCallback1[BulkWriteOpResultObject]): Unit
Perform a bulkWrite operation without a fluent API
Perform a bulkWrite operation without a fluent API
- operations
Bulk operations to perform.
- options
Optional settings.
- callback
The command result callback
bulkWrite(operations, options, callback)
Example: -
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
count(query: Any, options: RawOptions = js.native, callback: MongoCallback1[Int] = js.native): Promise[Int]
Count number of matching documents in the db to a query.
Count number of matching documents in the db to a query.
- query
The query for the count.
- options
Optional settings.
- callback
The command result callback
count(query, options, callback)
Example: -
def
createIndex(fieldOrSpec: Any, options: |[IndexOptions, RawOptions] = js.native): Promise[String]
Creates an index on the db and collection collection.
Creates an index on the db and collection collection.
- fieldOrSpec
Defines the index.
- options
Optional settings.
createIndex(fieldOrSpec, options[, callback])
Example: -
def
createIndex(fieldOrSpec: Any, callback: MongoCallback1[String]): Unit
Creates an index on the db and collection collection.
Creates an index on the db and collection collection.
- fieldOrSpec
Defines the index.
- callback
The command result callback
createIndex(fieldOrSpec, options[, callback])
Example: -
def
createIndex(fieldOrSpec: Any, options: |[IndexOptions, RawOptions], callback: MongoCallback1[String]): Unit
Creates an index on the db and collection collection.
Creates an index on the db and collection collection.
- fieldOrSpec
Defines the index.
- options
Optional settings.
- callback
The command result callback
createIndex(fieldOrSpec, options[, callback])
Example: -
def
createIndexes(indexSpecs: Array[Any], callback: Function): Unit
Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher.
Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher. Earlier version of MongoDB will throw a command not supported error. Index specifications are defined at
http://docs.mongodb.org/manual/reference/command/createIndexes/
. http://docs.mongodb.org/manual/reference/command/createIndexes/ }}}
- indexSpecs
An array of index specifications to be created
- callback
The command result callback
createIndexes(indexSpecs, callback)
Example: -
def
deleteMany(filter: Any, options: |[DeleteOptions, RawOptions] = js.native): Promise[DeleteWriteOpResult]
Delete multiple documents on MongoDB
Delete multiple documents on MongoDB
- filter
The Filter used to select the documents to remove
- options
Optional settings.
deleteMany(filter, options, callback)
Example: -
def
deleteMany(filter: Any, callback: MongoCallback1[DeleteWriteOpResult]): Unit
Delete multiple documents on MongoDB
Delete multiple documents on MongoDB
- filter
The Filter used to select the documents to remove
- callback
The command result callback
deleteMany(filter, options, callback)
Example: -
def
deleteMany(filter: Any, options: DeleteOptions, callback: MongoCallback1[DeleteWriteOpResult]): Unit
Delete multiple documents on MongoDB
Delete multiple documents on MongoDB
- filter
The Filter used to select the documents to remove
- options
Optional settings.
- callback
The command result callback
deleteMany(filter, options, callback)
Example: -
def
deleteOne(filter: Any, options: RawOptions = js.native): Promise[DeleteWriteOpResult]
Delete a document on MongoDB
Delete a document on MongoDB
- filter
The Filter used to select the document to remove
- options
Optional settings.
-
def
deleteOne(filter: Any, callback: Function): Unit
Delete a document on MongoDB
Delete a document on MongoDB
- filter
The Filter used to select the document to remove
- callback
The command result callback
-
def
deleteOne(filter: Any, options: RawOptions, callback: Function): Unit
Delete a document on MongoDB
Delete a document on MongoDB
- filter
The Filter used to select the document to remove
- options
Optional settings.
- callback
The command result callback
-
def
distinct(key: Any, query: Any, options: RawOptions, callback: Function): Unit
The distinct command returns returns a list of distinct values for the given key across a collection.
The distinct command returns returns a list of distinct values for the given key across a collection.
- key
Field of the document to find distinct values for.
- query
The query for filtering the set of documents to which we apply the distinct filter.
- options
Optional settings.
- callback
The command result callback
distinct(key, query, options, callback)
Example: -
def
drop(options: RawOptions = js.native, callback: Function1[MongoError, Any] = js.native): Promise[Any]
Drop the collection from the database, removing it permanently.
Drop the collection from the database, removing it permanently. New accesses will create a new collection.
- options
the optional settings
- callback
The optional command result callback
- returns
a completion promise, if the callback was not passed
drop([callback]): Promise
Example: -
def
dropIndex(indexName: String, options: RawOptions, callback: Function): Unit
Drops an index from this collection.
Drops an index from this collection.
- indexName
Name of the index to drop.
- options
Optional settings.
- callback
The command result callback
dropIndex(indexName, options, callback)
Example: -
def
dropIndexes(callback: Function): Unit
Drops all indexes from this collection.
Drops all indexes from this collection.
- callback
The command result callback
dropIndexes(callback)
Example: -
def
ensureIndex(fieldOrSpec: Any, options: |[IndexOptions, RawOptions] = js.native, callback: Function = js.native): Promise[Any]
Ensures that an index exists, if it does not it creates it
Ensures that an index exists, if it does not it creates it
- fieldOrSpec
Defines the index.
- options
Optional settings.
- callback
The command result callback
- returns
a completion promise if the callback is not present
ensureIndex(fieldOrSpec, options, callback)
Example: -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
find[A](selector: Any, projection: Any): Cursor[A]
Creates a cursor for a query that can be used to iterate over results from MongoDB
Creates a cursor for a query that can be used to iterate over results from MongoDB
find([selector[, projection]])
Example: -
def
find[A](selector: Any): Cursor[A]
Creates a cursor for a query that can be used to iterate over results from MongoDB
Creates a cursor for a query that can be used to iterate over results from MongoDB
find([selector[, projection]])
Example: -
def
find[A](): Cursor[A]
Creates a cursor for a query that can be used to iterate over results from MongoDB
Creates a cursor for a query that can be used to iterate over results from MongoDB
find([selector[, projection]])
Example: -
def
findAndRemove[A](query: Any, sort: Array[Any], options: RawOptions): Promise[A]
Find and remove a document.
Find and remove a document.
- query
Query object to locate the object to modify.
- sort
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
- options
Optional settings.
findAndRemove(query, sort, options, callback)
Example: -
def
findAndRemove(query: Any, sort: Array[Any], options: RawOptions, callback: Function): Unit
Find and remove a document.
Find and remove a document.
- query
Query object to locate the object to modify.
- sort
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
- options
Optional settings.
- callback
The command result callback
findAndRemove(query, sort, options, callback)
Example: -
def
findOneAndDelete(filter: Any, callback: Function): Unit
Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
- filter
Document selection filter.
- callback
The command result callback
findOneAndDelete(filter[, options], callback)
Example: -
def
findOneAndDelete(filter: Any, options: RawOptions, callback: Function): Unit
Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation.
- filter
Document selection filter.
- options
Optional settings.
- callback
The command result callback
findOneAndDelete(filter[, options], callback)
Example: -
def
findOneAndReplace(filter: Any, replacement: Any, options: RawOptions, callback: Function): Unit
Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation.
- filter
Document selection filter.
- replacement
Document replacing the matching document.
- options
Optional settings.
- callback
The command result callback
findOneAndReplace(filter, replacement, options, callback)
Example: -
def
findOneAndUpdate(filter: Any, update: Any, options: FindAndUpdateOptions = null): Promise[FindAndModifyWriteOpResult]
Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
- filter
Document selection filter.
- update
Update operations to be performed on the document
- options
Optional settings.
findOneAndUpdate(filter, update, options, callback)
Example: -
def
findOneAndUpdate(filter: Any, update: Any, callback: Function): Unit
Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
- filter
Document selection filter.
- update
Update operations to be performed on the document
- callback
The command result callback
findOneAndUpdate(filter, update, options, callback)
Example: -
def
findOneAndUpdate(filter: Any, update: Any, options: FindAndUpdateOptions, callback: Function): Unit
Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
Find a document and update it in one atomic operation, requires a write lock for the duration of the operation.
- filter
Document selection filter.
- update
Update operations to be performed on the document
- options
Optional settings.
- callback
The command result callback
findOneAndUpdate(filter, update, options, callback)
Example: -
def
geoHaystackSearch(x: Double, y: Double, options: RawOptions, callback: Function): Unit
Execute a geo search using a geo haystack index on a collection.
Execute a geo search using a geo haystack index on a collection.
- x
Point to search on the x axis, ensure the indexes are ordered in the same order.
- y
Point to search on the y axis, ensure the indexes are ordered in the same order.
- options
Optional settings.
- callback
The command result callback
-
def
geoNear(x: Double, y: Double, options: RawOptions, callback: Function): Unit
Execute the geoNear command to search for items in the collection
Execute the geoNear command to search for items in the collection
- x
Point to search on the x axis, ensure the indexes are ordered in the same order.
- y
Point to search on the y axis, ensure the indexes are ordered in the same order.
- options
Optional settings.
- callback
The command result callback
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
group(keys: Any, condition: Any, initial: Any, reduce: Any, finalize: Any, command: Any, options: RawOptions, callback: Function): Unit
- keys
An object, array or function expressing the keys to group by.
- condition
An optional condition that must be true for a row to be considered.
- initial
Initial value of the aggregation counter object.
- reduce
The reduce function aggregates (reduces) the objects iterated
- finalize
An optional function to be run on each item in the result set just before the item is returned.
- command
Specify if you wish to run using the internal group command or using eval, default is true.
- options
Optional settings
- callback
The command result callback
group(keys, condition, initial, reduce, finalize, command, options, callback)
Example: -
def
hasOwnProperty(v: String): Boolean
- Definition Classes
- Object
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
def
indexExists(indexes: String): Promise[Boolean]
Checks if one or more indexes exist on the collection, fails on first non-existing index
Checks if one or more indexes exist on the collection, fails on first non-existing index
- indexes
One or more index names to check.
- returns
Promise
indexExists(indexes, callback)
Example: -
def
indexExists(indexes: String, callback: MongoCallback1[Boolean]): Unit
Checks if one or more indexes exist on the collection, fails on first non-existing index
Checks if one or more indexes exist on the collection, fails on first non-existing index
- indexes
One or more index names to check.
- callback
The command result callback
- returns
Promise
indexExists(indexes, callback)
Example: -
def
indexExists(indexes: Array[String]): Promise[Boolean]
Checks if one or more indexes exist on the collection, fails on first non-existing index
Checks if one or more indexes exist on the collection, fails on first non-existing index
- indexes
One or more index names to check.
- returns
Promise
indexExists(indexes, callback)
Example: -
def
indexExists(indexes: Array[String], callback: MongoCallback1[Boolean]): Unit
Checks if one or more indexes exist on the collection, fails on first non-existing index
Checks if one or more indexes exist on the collection, fails on first non-existing index
- indexes
One or more index names to check.
- callback
The command result callback
- returns
Promise
indexExists(indexes, callback)
Example: -
def
indexInformation(options: RawOptions, callback: Function): Unit
Retrieves this collections index info.
Retrieves this collections index info.
- options
Optional settings.
- callback
The command result callback
indexInformation(options, callback)
Example: -
def
indexes(callback: Function): Unit
Retrieve all the indexes on the collection.
Retrieve all the indexes on the collection.
- callback
The command result callback
indexes(callback)
Example: -
def
initializeOrderedBulkOp(options: RawOptions, callback: Function): Unit
Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.
Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types.
- options
Optional settings.
- callback
The command result callback
initializeOrderedBulkOp(options, callback)
Example: -
def
initializeUnorderedBulkOp(options: RawOptions = js.native): Unit
Initiate a Out of order batch write operation.
Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
- options
Optional settings.
initializeUnorderedBulkOp(options)
Example: -
def
insertMany[T <: Any](docs: Array[T], options: |[WriteOptions, RawOptions] = js.native): Promise[InsertWriteOpResult]
Inserts an array of documents into MongoDB.
Inserts an array of documents into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- docs
Documents to insert.
- options
Optional settings.
insertMany(docs, options, callback): Promise
Example: -
def
insertMany[T <: Any](docs: Array[T], callback: MongoCallback1[InsertWriteOpResult]): Unit
Inserts an array of documents into MongoDB.
Inserts an array of documents into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- docs
Documents to insert.
- callback
The command result callback
insertMany(docs, options, callback): Promise
Example: -
def
insertMany[T <: Any](docs: Array[T], options: |[WriteOptions, RawOptions], callback: MongoCallback1[InsertWriteOpResult]): Unit
Inserts an array of documents into MongoDB.
Inserts an array of documents into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- docs
Documents to insert.
- options
Optional settings.
- callback
The command result callback
insertMany(docs, options, callback): Promise
Example: -
def
insertOne(doc: Any, options: |[WriteOptions, RawOptions] = js.native, callback: MongoCallback1[InsertWriteOpResult] = js.native): Promise[InsertWriteOpResult]
Inserts a single document into MongoDB.
Inserts a single document into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- doc
Document to insert.
- options
Optional settings.
- callback
The command result callback
-
def
isCapped(callback: MongoCallback1[Boolean] = js.native): Promise[Boolean]
Returns if the collection is a capped collection
Returns if the collection is a capped collection
- callback
The command result callback
isCapped(callback): Promise
Example: -
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPrototypeOf(v: Object): Boolean
- Definition Classes
- Object
-
def
listIndexes(options: RawOptions): Unit
Get the list of all indexes information for the collection.
Get the list of all indexes information for the collection.
- options
Optional settings.
-
def
mapReduce(map: String, reduce: String, options: RawOptions, callback: Function): Unit
Run Map Reduce across a collection.
Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
- map
The mapping function.
- reduce
The reduce function.
- options
Optional settings.
- callback
The command result callback.
- returns
a completion promise
-
def
mapReduce(map: String, reduce: Function, options: RawOptions, callback: Function): Unit
Run Map Reduce across a collection.
Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
- map
The mapping function.
- reduce
The reduce function.
- options
Optional settings.
- callback
The command result callback.
- returns
a completion promise
-
def
mapReduce(map: Function, reduce: String, options: RawOptions, callback: Function): Unit
Run Map Reduce across a collection.
Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
- map
The mapping function.
- reduce
The reduce function.
- options
Optional settings.
- callback
The command result callback.
- returns
a completion promise
-
def
mapReduce(map: Function, reduce: Function, options: RawOptions, callback: Function): Unit
Run Map Reduce across a collection.
Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
- map
The mapping function.
- reduce
The reduce function.
- options
Optional settings.
- callback
The command result callback.
- returns
a completion promise
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
options[A](callback: MongoCallback1[A] = js.native): Promise[A]
Returns the options of the collection.
Returns the options of the collection.
- callback
The results callback
- returns
the options of the collection.
-
def
parallelCollectionScan(options: RawOptions, callback: Function): Unit
Return N number of parallel cursors for a collection allowing parallel reading of entire collection.
Return N number of parallel cursors for a collection allowing parallel reading of entire collection. There are no ordering guarantees for returned results.
- options
Optional settings.
- callback
The command result callback.
- returns
N number of parallel cursors for a collection allowing parallel reading of entire collection.
-
def
propertyIsEnumerable(v: String): Boolean
- Definition Classes
- Object
-
def
reIndex[T <: Any](): Promise[T]
Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
-
def
reIndex(callback: Function): Unit
Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections.
- callback
The command result callback.
-
def
rename(newName: String, options: |[RenameOptions, RawOptions] = js.native, callback: MongoCallback0 = js.native): Promise[Unit]
Rename the collection.
Rename the collection.
- newName
New name of of the collection.
- options
Optional settings.
- callback
the optional callback
- returns
a completion promise
-
def
replaceOne[T <: Any](filter: Any, doc: Any, callback: MongoCallback1[T]): Promise[T]
Replace a document on MongoDB
Replace a document on MongoDB
- filter
The Filter used to select the document to update
- doc
The Document that replaces the matching document
- callback
The results callback
- returns
a promise of the document if the callback was not passed
-
def
replaceOne[T <: Any](filter: Any, doc: Any, options: |[ReplacementOptions, RawOptions], callback: MongoCallback1[T] = js.native): Promise[T]
Replace a document on MongoDB
Replace a document on MongoDB
- filter
The Filter used to select the document to update
- doc
The Document that replaces the matching document
- options
Optional settings.
- callback
The results callback
- returns
a promise of the document if the callback was not passed
-
def
stats(options: RawOptions = js.native, callback: MongoCallback1[CollectionStats] = js.native): Promise[CollectionStats]
Get all the collection statistics.
Get all the collection statistics.
- options
Optional settings.
- callback
The command result callback
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toLocaleString(): String
- Definition Classes
- Object
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
updateMany(filter: Any, update: Any, options: |[UpdateOptions, RawOptions] = js.native): Promise[UpdateWriteOpResultObject]
Update multiple documents on MongoDB
Update multiple documents on MongoDB
- filter
The Filter used to select the document to update
- update
The update operations to be applied to the document
- options
Optional settings.
-
def
updateMany(filter: Any, update: |[UpdateOptions, RawOptions], callback: Function2[MongoError, UpdateWriteOpResultObject, Any]): Unit
Update multiple documents on MongoDB
Update multiple documents on MongoDB
- filter
The Filter used to select the document to update
- update
The update operations to be applied to the document
- callback
The command result callback
-
def
updateMany(filter: Any, update: Any, options: |[UpdateOptions, RawOptions], callback: Function2[MongoError, UpdateWriteOpResultObject, Any]): Unit
Update multiple documents on MongoDB
Update multiple documents on MongoDB
- filter
The Filter used to select the document to update
- update
The update operations to be applied to the document
- options
Optional settings.
- callback
The command result callback
-
def
updateOne(filter: Any, update: Any, options: |[UpdateOptions, RawOptions] = js.native): Promise[UpdateWriteOpResultObject]
Update a single document on MongoDB
Update a single document on MongoDB
- filter
The Filter used to select the document to update
- update
The update operations to be applied to the document
- options
Optional settings.
- returns
a completion promise
-
def
updateOne(filter: Any, update: Any, callback: Function2[MongoError, UpdateWriteOpResultObject, Any]): Unit
Update a single document on MongoDB
Update a single document on MongoDB
- filter
The Filter used to select the document to update
- update
The update operations to be applied to the document
- callback
The command result callback
- returns
a completion promise
-
def
updateOne(filter: Any, update: Any, options: |[UpdateOptions, RawOptions], callback: Function2[MongoError, UpdateWriteOpResultObject, Any]): Unit
Update a single document on MongoDB
Update a single document on MongoDB
- filter
The Filter used to select the document to update
- update
The update operations to be applied to the document
- options
Optional settings.
- callback
The command result callback
- returns
a completion promise
-
def
valueOf(): Any
- Definition Classes
- Object
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
def
dropAllIndexes(callback: Function): Unit
Drops all indexes from this collection.
Drops all indexes from this collection.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use dropIndexes
dropAllIndexes(callback)
Example: -
def
findAndModify[A <: Any](query: Any, sort: Array[Any], doc: Any, options: RawOptions = null): Promise[A]
Find and update a document.
Find and update a document.
- query
Query object to locate the object to modify.
- sort
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
- options
Optional settings.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead
findAndModify(query, sort, doc, options, callback)
Example: -
def
findAndModify(query: Any, sort: Array[Any], doc: Any, callback: Function): Unit
Find and update a document.
Find and update a document.
- query
Query object to locate the object to modify.
- sort
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead
findAndModify(query, sort, doc, options, callback)
Example: -
def
findAndModify(query: Any, sort: Array[Any], doc: Any, options: RawOptions, callback: Function): Unit
Find and update a document.
Find and update a document.
- query
Query object to locate the object to modify.
- sort
If multiple docs match, choose the first one in the specified sort order as the object to manipulate.
- options
Optional settings.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead
findAndModify(query, sort, doc, options, callback)
Example: -
def
findOne[A <: Any](query: Any, options: RawOptions = js.native): Promise[A]
Fetches the first document that matches the query
Fetches the first document that matches the query
- query
Query for find Operation
- options
Optional settings.
- returns
a completion promise
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use find().limit(1).next(function(err, doc){})
findOne(query[, options], callback)
Example: -
def
findOne(query: Any, callback: Function): Unit
Fetches the first document that matches the query
Fetches the first document that matches the query
- query
Query for find Operation
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use find().limit(1).next(function(err, doc){})
findOne(query[, options], callback)
Example: -
def
findOne(query: Any, options: RawOptions, callback: Function): Unit
Fetches the first document that matches the query
Fetches the first document that matches the query
- query
Query for find Operation
- options
Optional settings.
- callback
The command result callback
- returns
a completion promise
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use find().limit(1).next(function(err, doc){})
findOne(query[, options], callback)
Example: -
def
insert(doc: Any, options: |[WriteOptions, RawOptions], callback: MongoCallback1[InsertWriteOpResult]): Unit
Inserts a single document or a an array of documents into MongoDB.
Inserts a single document or a an array of documents into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- doc
Document to insert.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use insertOne, insertMany or bulkWrite
-
def
insert(doc: Any, callback: MongoCallback1[InsertWriteOpResult]): Unit
Inserts a single document or a an array of documents into MongoDB.
Inserts a single document or a an array of documents into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- doc
Document to insert.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use insertOne, insertMany or bulkWrite
-
def
insert(doc: Any, options: |[WriteOptions, RawOptions] = js.native): Promise[InsertWriteOpResult]
Inserts a single document or a an array of documents into MongoDB.
Inserts a single document or a an array of documents into MongoDB. If documents passed in do not contain the _id field, one will be added to each of the documents missing it by the driver, mutating the document. This behavior can be overridden by setting the forceServerObjectId flag.
- doc
the given document
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use insertOne, insertMany or bulkWrite
-
def
remove(selector: Any, options: WriteOptions, callback: Function): Unit
Remove documents.
Remove documents.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use deleteOne, deleteMany or bulkWrite
-
def
remove(selector: Any): Unit
Remove documents.
Remove documents.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use deleteOne, deleteMany or bulkWrite
-
def
remove(): Unit
Remove documents.
Remove documents.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use deleteOne, deleteMany or bulkWrite
-
def
save(doc: Any, options: |[RawOptions, RawOptions] = js.native): Unit
Save a document.
Save a document. Simple full document replacement function. Not recommended for efficiency, use atomic operators and update instead for more efficient operations.
- doc
Document to save
- options
Optional settings.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use insertOne, insertMany, updateOne or updateMany
-
def
save(doc: Any, callback: Function): Unit
Save a document.
Save a document. Simple full document replacement function. Not recommended for efficiency, use atomic operators and update instead for more efficient operations.
- doc
Document to save
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use insertOne, insertMany, updateOne or updateMany
-
def
save(doc: Any, options: RawOptions, callback: Function): Unit
Save a document.
Save a document. Simple full document replacement function. Not recommended for efficiency, use atomic operators and update instead for more efficient operations.
- doc
Document to save
- options
Optional settings.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use insertOne, insertMany, updateOne or updateMany
-
def
update(selector: Any, document: Any, options: |[WriteOptions, RawOptions] = js.native): Promise[UpdateWriteOpResultObject]
Updates documents.
Updates documents.
- selector
The selector for the update operation.
- document
The update document.
- options
Optional settings.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use updateOne, updateMany or bulkWrite
-
def
update(selector: Any, document: Any): Promise[UpdateWriteOpResultObject]
Updates documents.
Updates documents.
- selector
The selector for the update operation.
- document
The update document.
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use updateOne, updateMany or bulkWrite
-
def
update(selector: Any, document: Any, callback: Function2[MongoError, UpdateWriteOpResultObject, Any]): Unit
Updates documents.
Updates documents.
- selector
The selector for the update operation.
- document
The update document.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use updateOne, updateMany or bulkWrite
-
def
update(selector: Any, document: Any, options: |[WriteOptions, RawOptions], callback: Function2[MongoError, UpdateWriteOpResultObject, Any]): Unit
Updates documents.
Updates documents.
- selector
The selector for the update operation.
- document
The update document.
- options
Optional settings.
- callback
The command result callback
- Annotations
- @deprecated
- Deprecated
(Since version 2.0) Use updateOne, updateMany or bulkWrite