Updating nested array of objects using $addToSet

Hello @Dev_Ops, you need to use arrayFilters option of the update operation to update specific element of an array based upon a condition matching the array element’s field (in your case the userId field).

See examples from documentation: Update Specific Elements of an Array of Documents

Also, see these posts with similar questions and answers:

1 Like