如何使用mongoose在MongoDb中获得创build的集合的ID?
我刚刚保存了一个嵌套集合时,如何获得ID?
码:
(Topic = schemaname from mongoose) Topic.findByIdAndUpdate({_id: data.topicId}, {data that im inserting in the nested collection})
该主题被更新,并添加一个嵌套的集合,也是一个ID。 有没有办法来返回插入的嵌套集合的ID?
尝试使用查询选项{new:true}
Topicopic.findByIdAndUpdate({_id: data.topicId}, {}, {new:true})