Is there anyone out there with experience in making a Node push function work on nested objects beyond just one level? I'm looking to delve deeper into a second id within the DB model.
// Functional code for updating a user at one level with one id
const update = await Budget.findOneAndUpdate(
{ '_id': `${id}` },
{
'$push': {
[`${sliceLeft}`]: location
}
}, { _id: true, new: true }
)
// Non-functional code! How can I target a second id in a nested object two levels deep?
let updateDeptArr = await Budget.findOneAndUpdate(
{ '_id': `${id}` }, //User id
{
'$push': {
[`${sliceLeft}.$._id`//Second ID ]: location// Data
}
}, { _id: true, new: true }
)