DAB
Search…
bulkUpdate
1
bulkUpdate(body, param)
Copied!
Due to the complexity and effectiveness, it is always a replace operation. Meaning the whole document body, except the id, will be replaced with the new one provided.
Partial updates are not supported.

Arguments

Body (array, required)

Body is always an array of objects. Every object needs to have an ID, otherwise, it'll yield a Not found error. Example:
1
[
2
{ _id: 'james-bond', name: 'James Bond 007' },
3
{ _id: 'jack-bauer-001', name: 'Mr. Jack Bauer' },
4
{ name: 'Johnie Englesh' } // id isn't provided here, it'll yield an error
5
...
6
]
Copied!

Params (required)

  • collection: Required, the name of collection you want to work with.
  • withDetail: default is false. If true, details of operation will be returned. It is an array of objects in the same order as body request above. See example below.

Response

Method should always return a response, eventhough one or more update could fail. If failed, those corresponding rows should tell why it failed, assuming it is enabled through withDetail parameter above.
The order of update result should match with the order of body request.
Promise rejection error should only occour when something very bad happened within the script.
Example:
1
{
2
success: true,
3
stat: {
4
ok: 1,
5
fail: 2,
6
total: 3
7
},
8
detail: [
9
{ _id: 'james-bond', success: true },
10
{ _id: 'jack-bauer-001', success: false, message: 'Document not found' },
11
{ _id: '337b116d-650e-4581-8bef-7b119467b05c', success: false, message: 'Document not found' }
12
]
13
}
Copied!
Last modified 3yr ago