Pub-sub that query Mongo View


#1

Hi everyone,
if you don’t mind, did anyone work with Mongo Views in Meteor? Can we use a View in pub-sub the same way we use Collections and keep subscription reactive?

I’m asking because I’m experiencing bizzare issues and not sure whether that’s an expected behavior or not. Basically:

  1. I have created a View in Mongo, that join couple of collections together;
  2. I query that view in publication in 2 different ways:
  • by document ids, like MyView.find({_id:{"$in": [IDS]}}, options);
  • by document ids + some additional filter, like MyView.find({_id:{"$in": [IDS]}, fieldN: “xxx”}, options);

What I see if I query documents by ids only:

  1. View return a bunch of documents and I see self.added fired for those documents.
  2. In about 3-5 seconds I see self.changed fired on same documents with an empty ‘fields’ parameter

What I see if I query documents by ids + filter:

  1. View return a bunch of documents and I see self.added fired for those documents.
  2. In about 3-5 seconds I see self.removed fired on same documents and those documents are removed from UI;

Why such a different behavior for 2, essentially, similar queries?