Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# mongo 2.0 driver get item after FindOneAndUpdateAsync

I have the following query in c#:

var filter = Builders<ME_UserInbox>.Filter.And(
                                                        Builders<ME_UserInbox>.Filter.Eq(n => n.UserId, userId),
                                                        Builders<ME_UserInbox>.Filter.ElemMatch(inbx => inbx.Inbox, msg => msg._id == msgId));

        var update = Builders<ME_UserInbox>.Update.PullFilter(inbx => inbx.Inbox, msgs => msgs._id == msgId);
        var upsert = new UpdateOptions()
        {
            IsUpsert = false
        };

        await collection.FindOneAndUpdateAsync(filter, update, upsert);

now, if I write .Result after that last line. do I get the document before it was updated or after?

TIA.

like image 463
Ori Refael Avatar asked Sep 25 '22 17:09

Ori Refael


1 Answers

The one before it was updated. Have a look here.

http://mongodb.github.io/mongo-csharp-driver/2.0/reference/driver/crud/writing/

like image 65
jvanrhyn Avatar answered Oct 03 '22 14:10

jvanrhyn