Complex query stopped working after update


#1

Hello everyone, I am Loupax and this is my first thread here. Nice meeting you :smile:

Yesterday, I attempted to update my application from Meteor 1.0.3.2 to Meteor 1.0.4.2. I was having this query that was working, but not anymore:

Meteor.publish('NearbyMessages', function(point) {
        var query = [];
        // Gather all messages that are nearby
        query.push({
             'location': 
                 $near: {
                     $geometry: {type: 'Point', coordinates: [point.longitude, point.latitude]},
                     $maxDistance: 1000
                 }
             }
         });
        // Also gather all the messages made by this.userId
        query.push({poster_id: this.userId});
        return MessagesCollection.find({$or: query});
});

I remember that I had the exact same problem in times before Meteor 1.0 so when I saw this code running on Meteor 1.0.3.2 I thought that it was now possible and I didn’t have to worry about this thing anymore…

After that, I tried publishing the result of both queries doing something like this:

var self = this;
MessagesCollection.find(nearbyQuery).forEach(function(msg){ 
    self.added('messages', msg._id, msg);
});
MessagesCollection.find(myMessagesQuery).forEach(function(msg){ 
    self.added('messages', msg._id, msg);
});
self.ready()

This would publish the results of both queries, but the result doesn’t seem to be reactive anymore.

Is what I’m trying to do possible? Is it on the roadmap? Any suggestion is welcome :smile:


#2

You should create a reproduction and post it on Github.


#3

The app is already on GitHub, the publication in question is located here.

Steps to replicate:

  1. Clone the app
  2. Run it
  3. Do meteor update at the project root and restart the application
  4. See the error messages on the console while nothing gets published
  5. Rerun the application with meteor --release 1.0.3.2 to see it working properly again