You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
811 B
30 lines
811 B
5 years ago
|
'use strict';
|
||
|
|
||
|
const OperationBase = require('./operation').OperationBase;
|
||
|
const updateCallback = require('./common_functions').updateCallback;
|
||
|
const updateDocuments = require('./common_functions').updateDocuments;
|
||
|
|
||
|
class UpdateManyOperation extends OperationBase {
|
||
|
constructor(collection, filter, update, options) {
|
||
|
super(options);
|
||
|
|
||
|
this.collection = collection;
|
||
|
this.filter = filter;
|
||
|
this.update = update;
|
||
|
}
|
||
|
|
||
|
execute(callback) {
|
||
|
const coll = this.collection;
|
||
|
const filter = this.filter;
|
||
|
const update = this.update;
|
||
|
const options = this.options;
|
||
|
|
||
|
// Set single document update
|
||
|
options.multi = true;
|
||
|
// Execute update
|
||
|
updateDocuments(coll, filter, update, options, (err, r) => updateCallback(err, r, callback));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = UpdateManyOperation;
|