0

I'd like to know the best way to update a nested object if the mongodb source collection has changed. I'm using the MongoDb .Net driver. Here is a short example:

Events collection:

[{ 
   _id: "59ad4e1f7a25f428bc6aeac7",
   EventName: "Event Foo",
   StartDate: "2017-08-31 09:00:00.000Z",
   Games: [
      { _id: "39ad4e1j7a26f42835gafac8", GameName: "Foo Game" },
      { _id: "19ad4e1f7a25f42835gaeac7", GameName: "Bar Game" }
   ],
   Language: { "59a6612f48ecdd4c8eaf1b09", "English" }
}]

Games collection

[    
   { _id: "39ad4e1j7a26f42835gafac8", GameName: "Foo Game" },
   { _id: "19ad4e1f7a25f42835gaeac7", GameName: "Bar Game" },
   { _id: "59a80d677a25f412ecda1b2d", GameName: "Foo-Bar Game" }
]

Now I have daily job that keeps my Games collection up to date.

Question: How can I keep my Events nested objects up to date id my Games collection changes ?

Community
  • 1
  • 1
Misi
  • 748
  • 5
  • 21
  • 46
  • 1
    If you keep only Game Ids in event class you wouldn't have such problems. Why do you even keep complete game in event class? – BOR4 Sep 04 '17 at 15:36
  • I thought about adding ids instead of the full objects, but... I don't want to make extra calls to the backend just for this ids. It just doesn't fit a real-life scenario. – Misi Sep 04 '17 at 18:58

0 Answers0