kill_cursors.js 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.KillCursorsOperation = void 0;
  4. const error_1 = require("../error");
  5. const operation_1 = require("./operation");
  6. class KillCursorsOperation extends operation_1.AbstractCallbackOperation {
  7. constructor(cursorId, ns, server, options) {
  8. super(options);
  9. this.ns = ns;
  10. this.cursorId = cursorId;
  11. this.server = server;
  12. }
  13. executeCallback(server, session, callback) {
  14. if (server !== this.server) {
  15. return callback(new error_1.MongoRuntimeError('Killcursor must run on the same server operation began on'));
  16. }
  17. const killCursors = this.ns.collection;
  18. if (killCursors == null) {
  19. // Cursors should have adopted the namespace returned by MongoDB
  20. // which should always defined a collection name (even a pseudo one, ex. db.aggregate())
  21. return callback(new error_1.MongoRuntimeError('A collection name must be determined before killCursors'));
  22. }
  23. const killCursorsCommand = {
  24. killCursors,
  25. cursors: [this.cursorId]
  26. };
  27. server.command(this.ns, killCursorsCommand, { session }, () => callback());
  28. }
  29. }
  30. exports.KillCursorsOperation = KillCursorsOperation;
  31. (0, operation_1.defineAspects)(KillCursorsOperation, [operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
  32. //# sourceMappingURL=kill_cursors.js.map