Convert ObjectID (Mongodb) to String in JavaScript

后端 未结 16 1289
青春惊慌失措
青春惊慌失措 2020-12-02 19:50

I want to convert ObjectID (Mongodb) to String in JavaScript. When I get a Object form MongoDB. it like as a object has: timestamp, second, inc, machine. I can\'t convert to

16条回答
  •  眼角桃花
    2020-12-02 20:43

    this works, You have mongodb object: ObjectId(507f191e810c19729de860ea), to get string value of _id, you just say ObjectId(507f191e810c19729de860ea).valueOf();

提交回复
热议问题