Mongodb Update Data Problem?

  node.js, question

The back end uses nodejs

The database operation is

var col_tenant_agent  = global.mongo.collection('tenant_agent');
 col_tenant_agent.update({"_id":ObjectId(tenantData.agentId)},{$set:{"state":tenantData.agentState}});

Both tenantData.agentId and tenantData.agentState already have data at the time of breakpoint test, so there should be no problem.

Database link global.mongo.collection (‘tenant _ agent’); There should also be no problem.

What’s wrong with the statement update?

I know the reason. The problem lies in the data type of _id, which is not a string, but ObjectId type data and needs type conversion.
var BSON = require(‘mongodb’).BSONPure;
8 var obj_id = BSON.ObjectID.createFromHexString(doc._id);