Add a new attribute to existing json object in node.js

后端 未结 7 1771
梦如初夏
梦如初夏 2021-01-17 07:16

I have an object like this

==================records=========={ Id: 5114a3c21203e0d811000088,
  userId: \'test\',
  sUserId: test,
  userName: \'test\',
  ur         


        
7条回答
  •  走了就别回头了
    2021-01-17 08:00

    You could also use the lean() method, e.g. const users = await Users.find().lean().exec()

    From the mongoose documentation:

    Documents returned from queries with the lean option enabled are plain javascript objects, not MongooseDocuments. They have no save method, getters/setters or other Mongoose magic applied

提交回复
热议问题