I’ve been trying to use positional operators to update an object property value to no avail. The code is straightforward and should work based on what I’ve watched video-wise and read documentation-wise. However, I’ve received an error every time without being able to make any progress in solving it.
await player.updateOne({ 'pity.type': type }, { $set: { 'pity.$.totalWishes': 1 } });
Using a positional operator, I’m attempting to set the totalWishes of the specific banner type to 1 but receive the error below.
MongoServerError: Cannot create field 'type' in element
Any and all help is appreciated.