I have the following model (only the improtant type):
public class Model
{
[BsonId]
public ObjectId ModelId;
public List<Game> Games;
}
public class Game
{
[BsonId]
public ObjectId GameId;
public List<Match> Matches;
}
public class Match
{
[BsonId]
public ObjectId MatchId;
public int[] Votes;
}
I have the following query:
var filter = Builders<Model>.Filter.And(
Builders<Model>.Filter.Eq(x => x.ModelId, modelId),
Builders<Model>.Filter.ElemMatch(x => x.Games, t => t.GameId == gameId));
var update = Builders<Model>.Update.Inc(x => x.Games[-1].Matches.First(t => t.MatchId == matchId).Votes[1], 2);
var options = new FindOneAndUpdateOptions<Model>()
{
ReturnDocument = ReturnDocument.After
};
Im using FindOneAndUpdateAsync
and Im able to retreive the data, but no changes are made.
Tried couple of times, still no change.
Answers to Comments:
Is something being returned?
Yes, the entire document. moreover, when I use fixed indexes, e.g: games[0].matches[0] everything works fine.
Did I try to run command in shell?
No, unfortunartly, so far I haven't tried to work with the shell