FindOneAndUpdate how to know if its an upsert or just the old record

Hi, I want to find a document based on its ID or create a new one with the same ID if not found. Im using this mongo package - - Go Packages

However, I dont know if its a new insert or get the old record. I guess it will help if there is a set operator for when its updating old record. Right now, we only have $set and $setOnInsert. will be helpful if we have $setOnUpdate, since I can differentiate between new insert and old record by updating the status of the document, for example. Is there no way around this? Thanks

Hi @freddie_mercury ,

The $set is happening on updates so its equivalent to what you expect from “$setOnUpdate” (if $setOnInsert is used as well)

Do you see a different behaviour?


I mean, I need to update only if its not upsert. but $set updates for both upsert and not upsert