Use case:
A Widget has many Gizmos. I’m using the Embedded Document pattern.
I need to update (potentially) each Gizmo. Can I do this with one updateOne
? I do understand that I need updateOne
instead of updateMany
since I’m working within ONE document in a collection.
I’m thinking that this won’t be possible because the query selector would need to specify which embedded documents to update.
Essentially what I’m looking for is something like:
`Widget.updateOne({
where: {_id: widget.id},
update: {
{gizmo.color: red WHERE gizmoId: gizmo[0].id},
{gizmo.color: blue WHERE gizmoId: gizmo[1].id}
}
})`