Here is the code I am working with: When I attempt to run it in Postman, I receive the following error message:
"message": "account.save is not a function"
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();
When I attempt to switch to using findOne(), a new issue arises:
"account.map is not a function"
I always get values from account, so why can't I map them? It's puzzling to me.
Your assistance would be greatly appreciated. Thank you