test that Last is not null in one of them. I'm not aware of any
the Mongo shell. Once you get it working there you can figure out how
to express the same update in C#. If you use temporary variables for
On Jan 18, 7:23 pm, rksprst <
alex.kamin...@gmail.com> wrote:
> It seems that I can only insert a whole document. I just want to
> update a value in the document. Is there a way to do it with the
> Update.Set or similar syntax? I also need to use a query so that it
> will find do the set only on the documents that fit a specified
> query.
>
> e.g. I want to do the following:
>
> QueryComplete query = Query.And(
> Query.EQ("MemGuid", memGuid),
> Query.EQ("Sessions.SessionId", sessionId)
> );
> var update = Update.PushAll("Sessions.$.Events",
> events.ToArray()).Set("Last ", utcNow);
>
> database.GetCollection<TrackedUser>("TrackedItems").Update(query,
> update, UpdateFlags.Upsert, SafeMode.True);
>
> But where the .Set("Last ", utcNow) only sets the value if it is null
> (i.e. the value doesn't exist).
>
> I'm using the 10gen c# driver. Also, per my other question on here