Upsert not returning object in callback
Closed this issue · 2 comments
I am having a problem when executing an upsert, that the object doesn't get returned in the callback. Also, the error object is null in the callback, so that is pretty weird. So the error object is null, and the object passed as a second parameter is undefined. When I check the database directly, the object is indeed there. Have you seen this before?
This is expected behavior.
Upsert is a special case of update, and the server doesn't return the object in that case. In fact, it doesn't return the object for inserts either. However, since the latest version of the object is known with inserts, Mongolian simply returns the same object.
Perhaps the same should be done for upserts? I'm not sure if it would be 100% correct to simply return the second parameter of upsert. It'd need to possibly merge the two objects?
Oh if that is the way it is supposed to be, then no worries. For some reason I expected it to be there. I needed to wait until the object was stored and the callback fired before I did something else with it, so I needed it in the callback. But there are other ways I can get the same results. Thanks for responding.