0

I have a document which has an array property that contains ids of documents stored in another collection, like below:

movie: { title: 'A title', genres: ['id_1', 'id_2', 'id_3', 'id_4' ] }

Now I want to pull all the related genres with one query for the specified movie. Is that possible with MongoDB driver for C# using Query.All()?

Élodie Petit
  • 5,774
  • 6
  • 50
  • 88

1 Answers1

0

As mongoDB does not support joins , there is no way Drivers of C# is going to help you. (https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/Uuqikhcxp4o) . In case you do joining on the client side , it will be very slow. Try to change the document structure and if possible use the sub-document of genres to make the advantage of the mongoDB. One of the suggestion I can give , if you have most the places you show small information about the genres , with Id store some more information but not all , so that while showing for movie you can just pick the document and show them easily and give the link in case they want more . More on SO : MongoDB and "joins"

     movie: { title: 'A title', genres: [{Id : 'id_1' , "Name" : "Classic"}, {Id :'id_2' , "Name" : "Romantic"} ] }
Community
  • 1
  • 1
Devesh
  • 4,500
  • 1
  • 17
  • 28