MongoDb, how to delete data according to a certain _id value

  mongodb, question

According to its own _id value, there are always problems in deleting.
collection.remove({_id: ObjectId(id)}, {w:1}, function (err) {

Prompt ObjectId not defined, write _ id directly: ID cannot be deleted, ID is a string

After reading the readme document of the official module,
Varobjectid = require (‘mongodb’). objectid is required first;
Then collect. findAndremove ({_ id: newobjectid (id)}) so that you can