kill_cursors.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.KillCursorsOperation = void 0;
  4. const responses_1 = require("../cmap/wire_protocol/responses");
  5. const error_1 = require("../error");
  6. const operation_1 = require("./operation");
  7. class KillCursorsOperation extends operation_1.AbstractOperation {
  8. constructor(cursorId, ns, server, options) {
  9. super(options);
  10. this.SERVER_COMMAND_RESPONSE_TYPE = responses_1.MongoDBResponse;
  11. this.ns = ns;
  12. this.cursorId = cursorId;
  13. this.server = server;
  14. }
  15. get commandName() {
  16. return 'killCursors';
  17. }
  18. buildCommand(_connection, _session) {
  19. const killCursors = this.ns.collection;
  20. if (killCursors == null) {
  21. // Cursors should have adopted the namespace returned by MongoDB
  22. // which should always defined a collection name (even a pseudo one, ex. db.aggregate())
  23. throw new error_1.MongoRuntimeError('A collection name must be determined before killCursors');
  24. }
  25. const killCursorsCommand = {
  26. killCursors,
  27. cursors: [this.cursorId]
  28. };
  29. return killCursorsCommand;
  30. }
  31. buildOptions(timeoutContext) {
  32. return {
  33. session: this.session,
  34. timeoutContext
  35. };
  36. }
  37. handleError(_error) {
  38. // The driver should never emit errors from killCursors, this is spec-ed behavior
  39. }
  40. }
  41. exports.KillCursorsOperation = KillCursorsOperation;
  42. (0, operation_1.defineAspects)(KillCursorsOperation, [operation_1.Aspect.MUST_SELECT_SAME_SERVER]);
  43. //# sourceMappingURL=kill_cursors.js.map