If I have an array inside of another array in MongoDB, how should I do to update a value in that array with mongoose? Right now the code looks like this, but nothing happens when it runs:
const newState = await MyModel.findOneAndUpdate(
{ code: code, 'array1.array2.identifier': identifier},
{ $set: { 'array1.array2.$.value': true } },
{ new: true }
);
In another place where I have only one array it works like a charm, and that codes looks like this:
const lobby = await Lobby.findOneAndUpdate(
{ code: code, 'array1.identifier': identifier},
{ $set: { 'array1.$.value': true } },
{ new: true }
);
So how do I get the first example where I have multiple arrays to work?