考虑这段代码,我需要创建或更新特定文档.
Inbox.model.findOneAndUpdate({ number: req.phone.number }, {
number: req.phone.number,
country: req.phone.country,
token: hat(),
appInstalled: true
}, { new: true, upsert: true }).then(function(inbox){
/*
do something here with inbox, but only if the inbox was created (not updated)
*/
});
Run Code Online (Sandbox Code Playgroud)
mongoose是否有能力区分是否创建或更新了文档?我需要new: true因为我需要调用函数inbox.