Skip to content

Commit

Permalink
Fix issue with Model.findById() no longer accepts a callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Romāns Djatlovs committed May 30, 2023
1 parent d0c5d6c commit 797dcf2
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,27 @@ function createFileSchema(bucket) {
*/
FileSchema.methods.unlink = function unlink(done) {
// obtain file details
return this.constructor.findById(
// eslint-disable-next-line no-underscore-dangle
this._id,
function afterFindFile(error, file) {
// back-off error
if (error) {
return done(error);
}
// remove file from gridfs
this.constructor
.findById(
// eslint-disable-next-line no-underscore-dangle
this._id
)
.then((file) => {
return bucket.deleteFile(
// eslint-disable-next-line no-underscore-dangle
file._id,
function afterDeleteFile($error /* , id */) {
done($error, file);
}
);
}
);
})
.catch((error) => {
done(error);
});

/*
*/
};

/* statics */
Expand Down

0 comments on commit 797dcf2

Please sign in to comment.