Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.close = function(callback) {
// Close the cursor if not needed
if(cursorId instanceof Long && cursorId.greaterThan(Long.fromInt(0))) {
try {
var command = new KillCursorCommand(this.db, [cursorId]);
// Added an empty callback to ensure we don't throw any null exceptions
db._executeQueryCommand(command, {connection:connection});
} catch(err) {}
}
// Null out the connection
connection = null;
// Reset cursor id
cursorId = Long.fromInt(0);
// Set to closed status
state = 'closed';
// Clear out all the items
items = null;
if(callback) {
callback(null, null);
}
}
Cursor.prototype.close = function(callback) {
var self = this
this.getMoreTimer && clearTimeout(this.getMoreTimer);
// Close the cursor if not needed
if(this.cursorId instanceof Long && this.cursorId.greaterThan(Long.fromInt(0))) {
try {
var command = new KillCursorCommand(this.db, [this.cursorId]);
// Added an empty callback to ensure we don't throw any null exceptions
this.db._executeQueryCommand(command, {read:self.read, raw:self.raw, connection:self.connection});
} catch(err) {}
}
// Null out the connection
self.connection = null;
// Reset cursor id
this.cursorId = Long.fromInt(0);
// Set to closed status
this.state = Cursor.CLOSED;
if(callback) {
callback(null, self);
this.returnKey = options.returnKey;
this.maxScan = options.maxScan;
this.min = options.min;
this.max = options.max;
this.showDiskLoc = options.showDiskLoc;
this.comment = options.comment;
this.tailableRetryInterval = options.tailableRetryInterval || 100;
this.exhaust = options.exhaust || false;
this.partial = options.partial || false;
this.slaveOk = options.slaveOk || false;
this.maxTimeMSValue = options.maxTimeMS;
this.connection = options.connection;
this.totalNumberOfRecords = 0;
this.items = [];
this.cursorId = Long.fromInt(0);
// This name
this.dbName = options.dbName;
// State variables for the cursor
this.state = Cursor.INIT;
// Keep track of the current query run
this.queryRun = false;
this.getMoreTimer = false;
// If we are using a specific db execute against it
if(this.dbName != null) {
this.collectionName = this.dbName + "." + this.collection.collectionName;
} else {
this.collectionName = (this.db.databaseName ? this.db.databaseName + "." : '') + this.collection.collectionName;
}
this.close = function(callback) {
// Close the cursor if not needed
if(cursorId instanceof Long && cursorId.greaterThan(Long.fromInt(0))) {
try {
var command = new KillCursorCommand(this.db, [cursorId]);
// Added an empty callback to ensure we don't throw any null exceptions
db._executeQueryCommand(command, {connection:connection});
} catch(err) {}
}
// Null out the connection
connection = null;
// Reset cursor id
cursorId = Long.fromInt(0);
// Set to closed status
state = 'closed';
// Clear out all the items
items = null;
Cursor.prototype.close = function(callback) {
var self = this
this.getMoreTimer && clearTimeout(this.getMoreTimer);
// Close the cursor if not needed
if(this.cursorId instanceof Long && this.cursorId.greaterThan(Long.fromInt(0))) {
try {
var command = new KillCursorCommand(this.db, [this.cursorId]);
// Added an empty callback to ensure we don't throw any null exceptions
this.db._executeQueryCommand(command, {readPreference:self.readPreference, raw:self.raw, connection:self.connection});
} catch(err) {}
}
// Null out the connection
self.connection = null;
// Reset cursor id
this.cursorId = Long.fromInt(0);
// Set to closed status
this.state = Cursor.CLOSED;
if(callback) {
callback(null, self);
self.items = [];
}
return this;
};
var CommandCursor = function(db, collection, command, options) {
// Ensure empty options if no options passed
options = options || {};
// Default cursor id is 0
var cursorId = Long.fromInt(0);
var zeroCursor = Long.fromInt(0);
var state = 'init';
// Hardcode batch size
command.cursor.batchSize = 1;
// BatchSize
var batchSize = command.cursor.batchSize || 0;
var raw = options.raw || false;
var readPreference = options.readPreference || 'primary';
// Checkout a connection
var connection = db.serverConfig.checkoutReader(readPreference);
// MaxTimeMS
var maxTimeMS = options.maxTimeMS;
Cursor.prototype.close = function(callback) {
var self = this
this.getMoreTimer && clearTimeout(this.getMoreTimer);
// Close the cursor if not needed
if(this.cursorId instanceof Long && this.cursorId.greaterThan(Long.fromInt(0))) {
try {
var command = new KillCursorCommand(this.db, [this.cursorId]);
// Added an empty callback to ensure we don't throw any null exceptions
this.db._executeQueryCommand(command, {read:self.read, raw:self.raw, connection:self.connection}, function() {});
} catch(err) {}
}
// Null out the connection
self.connection = null;
// Reset cursor id
this.cursorId = Long.fromInt(0);
// Set to closed status
this.state = Cursor.CLOSED;
if(callback) {
callback(null, self);
self.items = [];
}
return this;
};
var CommandCursor = function(db, collection, command, options) {
var self = this;
// Ensure empty options if no options passed
options = options || {};
// Set up
Readable.call(this, {objectMode: true});
// Default cursor id is 0
var cursorId = options.cursorId || Long.fromInt(0);
var zeroCursor = Long.fromInt(0);
var state = 'init';
var batchSize = options.batchSize || 0;
// Hardcode batch size
if(command && command.cursor) {
batchSize = command.cursor.batchSize || 0;
}
// BatchSize
var raw = options.raw || false;
var readPreference = options.readPreference || 'primary';
// Cursor namespace
this.ns = db.databaseName + "." + collection.collectionName
// Checkout a connection
this.maxScan = options.maxScan;
this.min = options.min;
this.max = options.max;
this.showDiskLoc = options.showDiskLoc;
this.comment = options.comment;
this.tailableRetryInterval = options.tailableRetryInterval || 100;
this.exhaust = options.exhaust || false;
this.partial = options.partial || false;
this.slaveOk = options.slaveOk || false;
this.maxTimeMSValue = options.maxTimeMS;
this.connection = options.connection;
this.transforms = options.transforms;
this.totalNumberOfRecords = 0;
this.items = [];
this.cursorId = Long.fromInt(0);
// This name
this.dbName = options.dbName;
// State variables for the cursor
this.state = Cursor.INIT;
// Keep track of the current query run
this.queryRun = false;
this.getMoreTimer = false;
// If we are using a specific db execute against it
if(this.dbName != null) {
this.collectionName = this.dbName + "." + this.collection.collectionName;
} else {
this.collectionName = (this.db.databaseName ? this.db.databaseName + "." : '') + this.collection.collectionName;
}
this.close = function(callback) {
// Close the cursor if not needed
if(cursorId instanceof Long && cursorId.greaterThan(Long.fromInt(0))) {
try {
var command = new KillCursorCommand(this.db, [cursorId]);
// Added an empty callback to ensure we don't throw any null exceptions
db._executeQueryCommand(command, {connection:connection});
} catch(err) {}
}
// Null out the connection
connection = null;
// Reset cursor id
cursorId = Long.fromInt(0);
// Set to closed status
state = 'closed';
// Clear out all the items
items = null;
if(callback) {
callback(null, null);
}
}