Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ Grid.prototype.collection = function (name) {
*/

Grid.prototype.remove = function (options, callback) {
var _id;
var _id = null;
if (options._id) {
_id = this.tryParseObjectId(options._id) || options._id;
}
if (!_id) {
_id = options.filename;
}
return this.mongo.GridStore.unlink(this.db, _id, options, callback);

var gridStore = new this.mongo.GridStore(this.db, _id, options.filename || null, "w", options, callback);
return gridStore.unlink(callback);
}

/**
Expand All @@ -103,14 +102,13 @@ Grid.prototype.remove = function (options, callback) {
*/

Grid.prototype.exist = function (options, callback) {
var _id;
if (options._id) {
_id = this.tryParseObjectId(options._id) || options._id;
}
if (!_id) {
_id = options.filename;
}
return this.mongo.GridStore.exist(this.db, _id, options.root, callback);
var query = {};
if (options._id)
query._id = this.tryParseObjectId(options._id) || options._id;
if (options.filename)
query.filename = options.filename;

return this.mongo.GridStore.exist(this.db, query, options.root, options, callback);
}

/**
Expand Down