【发布时间】:2022-01-26 10:40:30
【问题描述】:
我正在插入这样的新记录(
Book
是模型):
var ext = 'pdf'
var dataToInsert = {
'author': 'ABC',
'country': 'US',
'file_name': ''
}
var new_book = new Book( dataToInsert );
await new_book.save();
const file_name = new_book._id + '.' + ext
//-- update the document with the new file_name
在这里,不是使用
findOneAndUpdate()
来更新
file_name
字段,有没有更好的方法,比如一次性完成?