Return with relations in publish

Hey, I am using ‘publish’ when fetching ‘games’ collection to retrieve only current user games.
I want to retrieve all the players of the the game(s).
Player is a relation of game.
I wonder how should I do that? What is the most recomended way?
Retrieve in the publish OR make it command OR just retrieve all games and after that forEach every game and retrieve his players?


It depends how much reactive it should be, if players list should update automatically.
If you dont need it to be reactive it can be done by simple fetching on server side and returning both cursors.

If you need it to be reactive, people use publish composite package most of the time.

Look i have 2 complex fetches:

  1. Fetch games feed with count of players (not player object, only count of them)
  2. Fetch 1 game with all of his players

I prefer real-time fetch…
What you recommend for this 2 fetches? And please, if you can - provide example of link to tutorial. Thanks man


depends how u structure your data schema and what ratio of normalization/denormalization u want to have.

If u keep player ID’s in game document, u can count them right away of that collection
If u keep game ID’s in player document, you can list all players for given game by simple cursor without joins

But than you need to take care of syncing these 2 fields.

Than there is that normalized form when you are not syncing, but than you need to do joins between collections and if you want to have it reactive both ways (if any of collection query yeld new results) than you use something like publish-composite.
But than count of operations per every little change grow exponentionaly based on how many queries u watch and try to have in sync.

I cant go much deeper, as I dont use composite.

In my usecase I am deeply focused on relations and suggestion engine based on likes of the user and matching him to similar users so I can suggest based on that… well, for that seems Neo4j as the good db. I am still using mongodb for realtime cooperation activities of users etc. As oplog tailing rocks

But for relations heavy data I went the graph db way.

In this case, there is any solution to get Post and his Category inside the Post?
I mean, I want to make one HTTP request and get all information I need; instead of making some HTTP requests and make the waiting time longer…