c# - How do I properly format this MongoDB update clause? -
i have following document:
{ "_id": { "$oid": "55e1f841ff149c2228a5c33d" }, "status": "open", "date": "8/30/2015", "contestname": "test contest", "searchablecontestname": "test contest", "classname": "test", "searchableclassname": "test", "judges": [ { "name": "first last", "isheadjudge": null, "_id": { "$oid": "55e20962ff149c1f70d1aab0" }, "contestscores": null }, { "name": "another name", "isheadjudge": null, "_id": { "$oid": "55e20947ff149c1f70d1aaaf" }, "contestscores": [ 1, 2, 3, 4, 5, 6 ] },
...
there multiple judges in list. want selectively update contest scores "first last" name individual. i'm having difficulty figuring out proper way build filters this. have:
public async void updatecontestscores(contestjudge judgedata, objectid contestid) { var contests = _db.getcollection<bsondocument>("contests"); var builder = builders<bsondocument>.filter; var updatefilter = builder.eq("_id", contestid) & builder.eq("judges.name", judgedata.name); var update = builders<bsondocument>.update.set("judges.contestscores", judgedata.contestscores); await contests.updateoneasync(updatefilter, update); }
this throws bulk update error of form. how go updating empty contest score field? i'm unsure of proper filter syntax such thing.
Comments
Post a Comment