MongoDb : Error: Cannot use a writeConcern without a provided callback on remove

7 mongodb node.js

using MongoDB w node.js, I am trying to remove an item after finding it .. but it's failing

  1. I get the collection (db.collection)
  2. I find the item ( collection.findOne )
  3. I remove the item from the collection

what's wrong in my script ?

exports.revokeRefreshToken = function (refreshToken,  callback) {
  db.collection('oauth_refresh_tokens', function(err, collection) {
    collection.findOne({'refreshToken': refreshToken}, function(err, item) {
        db.collection('oauth_refresh_tokens').remove({_id: item._id});
        callback(err );
    });
 });
Run Code Online (Sandbox Code Playgroud)

};

小智 7

我修改了撤销功能以包含回调

exports.revokeRefreshToken = function (refreshToken,  callback) {
  db.collection('oauth_refresh_tokens', function(err, collection) {
      collection.remove({'refreshToken': refreshToken} , function(err, result) {
          callback(err);
      });
  });
};
Run Code Online (Sandbox Code Playgroud)