- Stitch >
- MongoDB Atlas >
- Reference >
- MongoDB Actions
collection.updateMany()¶
On this page
Definition¶
-
collection.
updateMany
()¶
Update one or more documents in a collection based on a query filter.
Usage¶
Example¶
- Functions
- JavaScript SDK
- Android SDK
- iOS SDK
To call the collection.updateMany()
action from a
Function, get a collection handle with
database.collection()
then call the handle’s
updateMany()
method.
To call the collection.updateMany()
action from a
JavaScript SDK, use the RemoteMongoCollection.updateMany() method.
To call the collection.updateMany()
action from the
Java/Android SDK, use the RemoteMongoCollection.updateMany() method.
To call the collection.updateMany()
action from the
Swift/iOS SDK, use the RemoteMongoCollection.updateMany() method.
Parameters¶
- Functions
- JavaScript SDK
- Android SDK
- iOS SDK
The collection.updateMany()
action has the following form:
Parameter | Description |
---|---|
Query Filter filter: <document> |
Required. A standard MongoDB query document that specifies which documents to update. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
Update Operation update: <document> |
Required. A standard MongoDB update document that specifies the update operation to perform on all documents that match the query. You can use most update operators. |
Update Options options: <document> |
A document that specifies configuration options for the query.
The |
Upsert options.upsert: <boolean> |
Optional. Default: false . A boolean that, if true ,
indicates that MongoDB should insert a new document that
matches the query filter when the query does not match any
existing documents in the collection. |
The updateMany() method has the following form:
Parameter | Description |
---|---|
Query Filter filter: <document> |
Required. A standard MongoDB query document that specifies which documents to update. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
Update Operation update: <document> |
Required. A standard MongoDB update document that specifies the update operation to perform on all documents that match the query. You can use most update operators. |
Update Options options: <document> |
A document that specifies configuration options for the query.
The |
Upsert options.upsert: <boolean> |
Optional. Default: false . A boolean that, if true ,
indicates that MongoDB should insert a new document that
matches the query filter when the query does not match any
existing documents in the collection. |
The updateMany() method has the following form:
Parameter | Description |
---|---|
Query Filter filter: <document> |
Required. A standard MongoDB query document that specifies which documents to update. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
Update Operation update: <document> |
Required. A standard MongoDB update document that specifies the update operation to perform on all documents that match the query. You can use most update operators. |
Update Options options: <document> |
A document that specifies configuration options for the query.
The |
Upsert options.upsert: <boolean> |
Optional. Default: false . A boolean that, if true ,
indicates that MongoDB should insert a new document that
matches the query filter when the query does not match any
existing documents in the collection. |
The updateMany() method has the following form:
Parameter | Description |
---|---|
Query Filter filter: <document> |
Required. A standard MongoDB query document that specifies which documents to update. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
Update Operation update: <document> |
Required. A standard MongoDB update document that specifies the update operation to perform on all documents that match the query. You can use most update operators. |
Update Options options: <document> |
A document that specifies configuration options for the query.
The |
Upsert options.upsert: <boolean> |
Optional. Default: false . A boolean that, if true ,
indicates that MongoDB should insert a new document that
matches the query filter when the query does not match any
existing documents in the collection. |
Return Value¶
- Functions
- JavaScript SDK
- Android SDK
- iOS SDK
The collection.updateMany()
action returns a Promise that
resolves to a document that describes the update operation.
The RemoteMongoCollection.updateMany() method returns a Promise that resolves to a RemoteUpdateResult object that describes the update operation.
The RemoteMongoCollection.updateMany() method returns a Task that resolves to a RemoteUpdateResult object that describes the update operation.
The RemoteMongoCollection.updateMany() method returns a StitchResult enum that resolves to a RemoteUpdateResult object that describes the update operation.
Value | Description |
---|---|
Matched Count result.matchedCount: <integer> result.matchedCount: <integer> result.matchedCount: <Long> result.matchedCount: <Int> |
The number of documents in the collection that match the provided query filter. |
Modified Count result.modifiedCount: <integer> result.modifiedCount: <integer> result.modifiedCount: <Long> result.modifiedCount: <Int> |
The number of documents in the collection that were modified by the update operation. |
Upserted ID result.upsertedId: <ObjectID> result.upsertedId: <ObjectID> result.upsertedId: <ObjectID> result.upsertedId: <ObjectID> |
The _id value of the document inserted by an upsert
operation. This value is only present when the upsert option
is enabled and the update query does not match any documents. |