i wanted to make a query that returns me the following data in mongodb

Asked

Viewed 33 times

2

COLECTION GAMES

{
  id : 10,
  casa : "Sport",
  visitante : "Chapecoense",
  horario : "2017-07-20 11:00:00"
}

GAMBLER COLLECTION

{
  nome : "wedson",
  apostas : [
   {
     idjogo : 10,
     opcao : 1,
     valores : 1
   }
  ]
}

i wanted to make a query that returns me the following

{
  nome : "wedson",
  apostas : [
   {
     idjogo : 10,
     opcao : 1,
     valores : 1,
     id : 10,
     casa : "Sport",
     visitante : "Chapecoense",
     horario : "2017-07-20 11:00:00",
   }
  ]
}

in case it would be the betting table with the complete data of the games, I did not want to register the bet with all the dice only with the id and then try to pull everything I need this way, if I am wrong correct me, but giving this idea of how to pull I am grateful :)

  • You are using Mongo as a relational database, the ideal is not to use it like this. The best way would be to put all the information inside a single Collection (document).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.