GJain
GJain

Reputation: 5093

FindAndModify: get newDocument along with info whether doc was inserted or updated

Using findAndModify:

I get the new document, how can I know if an insert/update was happened?

Upvotes: 1

Views: 42

Answers (1)

shmit
shmit

Reputation: 2524

One possible, though not the most efficient way, can be to check for presence of record before issuing the modify command because if you need the new record, then you cannot check if it previously existed.

Upvotes: 1

Related Questions