MongoDB update field value as ObjectId

Hello, using MongoDB am trying to update field value as ObjectId, but it is updating as string as follows and the table relation is failing.

{ 
   "userName":"adam",
   "roleId": "ObjectId("603ca6cd58f2c71d50bd4cb0")"
}

Could some one please help me the update the value as follows

{ 
   "userName":"adam",
   "roleId": ObjectId("603ca6cd58f2c71d50bd4cb0")
}

Thanks in advance…

Yes, this is currently not possible. Currently, ObjectID is just supported when updating the collection’s ID. Will add it to my to-do list.

1 Like