Initial commit
This commit is contained in:
33
node_modules/mongodb/lib/operations/re_index.js
generated
vendored
Normal file
33
node_modules/mongodb/lib/operations/re_index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
const Aspect = require('./operation').Aspect;
|
||||
const defineAspects = require('./operation').defineAspects;
|
||||
const CommandOperationV2 = require('./command_v2');
|
||||
const serverType = require('../core/sdam/common').serverType;
|
||||
const ServerType = require('../core/sdam/common').ServerType;
|
||||
const MongoError = require('../core').MongoError;
|
||||
|
||||
class ReIndexOperation extends CommandOperationV2 {
|
||||
constructor(collection, options) {
|
||||
super(collection, options);
|
||||
this.collectionName = collection.collectionName;
|
||||
}
|
||||
|
||||
execute(server, callback) {
|
||||
if (serverType(server) !== ServerType.Standalone) {
|
||||
callback(new MongoError(`reIndex can only be executed on standalone servers.`));
|
||||
return;
|
||||
}
|
||||
super.executeCommand(server, { reIndex: this.collectionName }, (err, result) => {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
callback(null, !!result.ok);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
defineAspects(ReIndexOperation, [Aspect.EXECUTE_WITH_SELECTION]);
|
||||
|
||||
module.exports = ReIndexOperation;
|
||||
Reference in New Issue
Block a user