Javascript .save不是函数,.map不是更新文档时的函数

Javascript .save不是函数,.map不是更新文档时的函数,javascript,mongodb,mongoose,mongodb-query,mongoose-schema,Javascript,Mongodb,Mongoose,Mongodb Query,Mongoose Schema,我有以下代码:当我试图从邮递员那里得到信息时,它说: “消息”:“account.save不是一个函数” 如果我尝试更改为findOne(),它会说 “account.map不是一个函数” 帐户总是返回值,那么为什么它不能映射我不明白 谢谢你的帮助。谢谢。find()返回一个数组,这样您就可以运行了,但您需要。分别保存()每个文档: const accounts = await Account.find({ "buildings.gateways.devices.verificationCode

我有以下代码:当我试图从邮递员那里得到信息时,它说:

“消息”:“account.save不是一个函数”

如果我尝试更改为findOne(),它会说

“account.map不是一个函数”

帐户总是返回值,那么为什么它不能映射我不明白

谢谢你的帮助。谢谢
。find()
返回一个数组,这样您就可以运行了,但您需要
。分别保存()
每个文档:

const accounts = await Account.find({ "buildings.gateways.devices.verificationCode": code })
var accountId = account ? account.map(item => item._id) : null

for(let account of accounts){
    await account.save();
}
.findOne()
(等待)返回单个文档,因此无法使用
.map()

const accounts = await Account.find({ "buildings.gateways.devices.verificationCode": code })
var accountId = account ? account.map(item => item._id) : null

for(let account of accounts){
    await account.save();
}
const account = await Account.findOne({ "buildings.gateways.devices.verificationCode": code })
var accountId = account ? account._id : null

account.save();