re_index.js 670 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. const CommandOperation = require('./command');
  3. const handleCallback = require('../utils').handleCallback;
  4. class ReIndexOperation extends CommandOperation {
  5. constructor(collection, options) {
  6. super(collection.s.db, options, collection);
  7. }
  8. _buildCommand() {
  9. const collection = this.collection;
  10. const cmd = { reIndex: collection.collectionName };
  11. return cmd;
  12. }
  13. execute(callback) {
  14. super.execute((err, result) => {
  15. if (callback == null) return;
  16. if (err) return handleCallback(callback, err, null);
  17. handleCallback(callback, null, result.ok ? true : false);
  18. });
  19. }
  20. }
  21. module.exports = ReIndexOperation;