【发布时间】:2020-04-20 16:54:05
【问题描述】:
我有以下代码:当我尝试从邮递员那里说:
"message": "account.save 不是函数"
const account = await Account.find({ "buildings.gateways.devices.verificationCode": code })
var accountId = account ? account.map(item => item._id) : null
const buildings = _.flatMap(account, a => a.buildings)
const gateways = _.flatMap(buildings, b => b.gateways);
const devices = _.flatMap(gateways, g => g.devices);
// finding deviceId to insert for user from that account
const device = _.filter(devices, d => d.verificationCode === code);
device.patientFirstName = req.body.firstName;
device.patientLastName = req.body.lastName;
account.save();
如果我尝试更改为 findOne() 那么它会说
“account.map 不是函数”
帐户总是返回值,那么为什么它不能映射我不明白。
感谢您的帮助。谢谢
【问题讨论】:
标签: javascript mongodb mongoose mongodb-query mongoose-schema