drop.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.DropDatabaseOperation = exports.DropCollectionOperation = void 0;
  4. const command_1 = require("./command");
  5. const operation_1 = require("./operation");
  6. /** @internal */
  7. class DropCollectionOperation extends command_1.CommandOperation {
  8. constructor(db, name, options) {
  9. super(db, options);
  10. this.options = options;
  11. this.name = name;
  12. }
  13. execute(server, session, callback) {
  14. super.executeCommand(server, session, { drop: this.name }, (err, result) => {
  15. if (err)
  16. return callback(err);
  17. if (result.ok)
  18. return callback(undefined, true);
  19. callback(undefined, false);
  20. });
  21. }
  22. }
  23. exports.DropCollectionOperation = DropCollectionOperation;
  24. /** @internal */
  25. class DropDatabaseOperation extends command_1.CommandOperation {
  26. constructor(db, options) {
  27. super(db, options);
  28. this.options = options;
  29. }
  30. execute(server, session, callback) {
  31. super.executeCommand(server, session, { dropDatabase: 1 }, (err, result) => {
  32. if (err)
  33. return callback(err);
  34. if (result.ok)
  35. return callback(undefined, true);
  36. callback(undefined, false);
  37. });
  38. }
  39. }
  40. exports.DropDatabaseOperation = DropDatabaseOperation;
  41. (0, operation_1.defineAspects)(DropCollectionOperation, [operation_1.Aspect.WRITE_OPERATION]);
  42. (0, operation_1.defineAspects)(DropDatabaseOperation, [operation_1.Aspect.WRITE_OPERATION]);
  43. //# sourceMappingURL=drop.js.map