is not available as an option for the query. I believe that in MongoDB you cannot do an upsert based on a value of an object field in a embedded array.
That being said even in pure MongoDB query terms your schema may need to be adjusted or use additional application logic in order to achieve what you want . This leads me to my next point, as I believe what you want can be achieved by Cloud Code. In order for me to help you with that I would need to know more details of how you edit the data through your application.
A simple approach will be to subscribe to the beforeUpdate
event of your Content Type as explained here
and make a select based on your filter to check if the the contacts field contains the value you want so you update or it needs to be inserted. Keep in mind this is just a rough example of how you can do it and I will need more details for an exact approach. This however, may not be the fastest and most performant approach.
Also note that the $addToSet operator appears to be the closest to what you would like to achieve.
Do not hesitate to contact us again if you need further assistance.
Telerik by Progress