get_more.js 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.GetMoreOperation = void 0;
  4. const error_1 = require("../error");
  5. const utils_1 = require("../utils");
  6. const operation_1 = require("./operation");
  7. /** @internal */
  8. class GetMoreOperation extends operation_1.AbstractOperation {
  9. constructor(ns, cursorId, server, options = {}) {
  10. super(options);
  11. this.options = options;
  12. // comment on getMore is only supported for server versions 4.4 and above
  13. if ((0, utils_1.maxWireVersion)(server) < 9) {
  14. delete this.options.comment;
  15. }
  16. this.ns = ns;
  17. this.cursorId = cursorId;
  18. this.server = server;
  19. }
  20. /**
  21. * Although there is a server already associated with the get more operation, the signature
  22. * for execute passes a server so we will just use that one.
  23. */
  24. execute(server, session, callback) {
  25. if (server !== this.server) {
  26. return callback(new error_1.MongoRuntimeError('Getmore must run on the same server operation began on'));
  27. }
  28. server.getMore(this.ns, this.cursorId, this.options, callback);
  29. }
  30. }
  31. exports.GetMoreOperation = GetMoreOperation;
  32. (0, operation_1.defineAspects)(GetMoreOperation, [operation_1.Aspect.READ_OPERATION, operation_1.Aspect.CURSOR_ITERATING]);
  33. //# sourceMappingURL=get_more.js.map