Urigo / meteor-rxjs

Exposing Mongo Cursor as RxJS Observable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to do nested data?

veeramarni opened this issue · comments

Hi,

I want to modify the collection further querying different collection(nested). How to achieve it?

Collections

Boxes : { _id: 'sdfs', server: 'server_id' ...}

Servers: { _id: 'server_id', ....}

I do publishComposite at server end and i need to receive same data at client.


const modified = (observable) => {
   observable.server = Server.findOne({_id: observable.server});
  return observable;
}
    
.mergeMap(() => 
Boxes
    .find()
    .forEach( observable => modified(observable)

But not receiving the data I need.

@veeramarni, as far as I understood, you have two streams (two Meteor collections), and each one has his own data, and you want to merge them into a single stream? If so, you can use combineLatest operator to combine the data and return a single stream.
We have some examples for that in angular-meteor.com tutorials for merging streams:
https://angular-meteor.com/tutorials/socially/angular2/search-sort-pagination-and-reactive-vars
https://angular-meteor.com/tutorials/whatsapp2/meteor/meteor-server-side