Closed cbratschi closed 7 years ago
The following code in schema.js should be changed from:
GridFSSchema.statics.unlinkById = GridFSSchema.statics.unlink = function(id, done) { this.findById(id).exec(function(error, foundInstance) { foundInstance.unlink(done); }); };
To:
GridFSSchema.statics.unlinkById = GridFSSchema.statics.unlink = function(id, done) { this.findById(id).exec((error, foundInstance) => { if (error) { return done(error); } if (!foundInstance) { return done(new Error('not found')); } foundInstance.unlink(done); }); };
Currently if the file does not exist in GridFS the whole app will crash.
@cbratschi I will appreciate PR for this.
Thanks.
@cbratschi Fixed and PR merged. Thanks
The following code in schema.js should be changed from:
To:
Currently if the file does not exist in GridFS the whole app will crash.