Closed oreporan closed 8 years ago
I didn't understand yet why more than 1 level nesting is bad practice.
2015-10-16 15:19 GMT+03:00 oreporan notifications@github.com:
I think this will be a problem, look at this model of a league object
{id : xyz, games : [ {id: 123, users : [ {id: 1a1b, attending : 0}, {id: x6a5, attending : 1} ]} ]}
That would mean that if I want to make user 1a1b join the game, I need to go 3-level deep of nesting. From what I understand this is a) very complex query, and b) not recommened (you should not have more than 1 level of nesting)
I'm trying to figure out the best way to do this with 1 query, but if I can't it would mean that I would first get the game object, update the user, and push it back in to the league
— Reply to this email directly or view it on GitHub https://github.com/oreporan/wePlayMin/issues/23.
http://stackoverflow.com/questions/13791293/mongodb-nesting-or-splitting-best-practices
On 17 באוק 2015, at 10:29, Yahav notifications@github.com wrote:
I didn't understand yet why more than 1 level nesting is bad practice.
2015-10-16 15:19 GMT+03:00 oreporan notifications@github.com:
I think this will be a problem, look at this model of a league object
{id : xyz, games : [ {id: 123, users : [ {id: 1a1b, attending : 0}, {id: x6a5, attending : 1} ]} ]}
That would mean that if I want to make user 1a1b join the game, I need to go 3-level deep of nesting. From what I understand this is a) very complex query, and b) not recommened (you should not have more than 1 level of nesting)
I'm trying to figure out the best way to do this with 1 query, but if I can't it would mean that I would first get the game object, update the user, and push it back in to the league
— Reply to this email directly or view it on GitHub https://github.com/oreporan/wePlayMin/issues/23.
— Reply to this email directly or view it on GitHub.
Apparently mongodb becomes uneffecient when you need to read/write a lot from a 3rd level of nesting. From what I am reading, at some point you need to take out the objects in to new collections...
OK, and there is no option to mangage the games in level 2? and than game's user will be at level 3
2015-10-17 17:46 GMT+03:00 oreporan notifications@github.com:
Apparently mongodb becomes uneffecient when you need to read/write a lot from a 3rd level of nesting. From what I am reading, at some point you need to take out the objects in to new collections...
— Reply to this email directly or view it on GitHub https://github.com/oreporan/wePlayMin/issues/23#issuecomment-148920932.
You mean do 2 queries when I want to update a user in a game?
No. Sorry, last message wasn't clear enough. There is no option to manage the games in level 2, inside the league ? And than game's users will be at level 3, which is good enough
On Sat, Oct 17, 2015, 19:45 oreporan notifications@github.com wrote:
You mean do 2 queries when I want to update a user in a game?
— Reply to this email directly or view it on GitHub https://github.com/oreporan/wePlayMin/issues/23#issuecomment-148933438.
The problem are in the queries joinGame
and leaveGame
- when I need to read/write to that 3rd level.
This is where most of the work will be, so its a problem
I think this will be a problem, look at this model of a
league
object{id : xyz, games : [ {id: 123, users : [ {id: 1a1b, attending : 0}, {id: x6a5, attending : 1} ]} ]}
That would mean that if I want to make user
1a1b
join the game, I need to go 3-level deep of nesting. From what I understand this is a) very complex query, and b) not recommened (you should not have more than 1 level of nesting)I'm trying to figure out the best way to do this with 1 query, but if I can't it would mean that I would first get the game object, update the user, and push it back in to the league