Mongodb query fails after update to Meteor 2.2


After update to Meteor 2.2 this publish started to fail.

Meteor.publish('clapsForPoemByUser', function(poemId) {
    return Claps.find(
      { poemId }, 
        fields: { 
          usersclaps: { $elemMatch: { userId: this.userId } },
          'usersclaps.claps': 1

Returned error is:

I20210529-22:58:56.780(2)? Exception from sub clapsForPoemByUser id oTQsETkYuHqdDkTFa Error: Exception while polling query {"collectionName":"claps","selector":{"poemId":"5ms7mgzLBQjAcDscq"},"options":{"transform":null,"fields":{"usersclaps":{"$elemMatch":{"userId":"8hqK63ZmjxbEc4SqB"}},"usersclaps.claps":1}}}: Path collision at usersclaps.claps remaining portion claps
I20210529-22:58:56.780(2)?     at PollingObserveDriver._pollMongo (packages/mongo/polling_observe_driver.js:165:11)
I20210529-22:58:56.781(2)?     at Object.task (packages/mongo/polling_observe_driver.js:93:12)
I20210529-22:58:56.781(2)?     at Meteor._SynchronousQueue.SQp._run (packages/meteor.js:917:16)
I20210529-22:58:56.781(2)?     at packages/meteor.js:894:12

When I remove this line it starts to work.

usersclaps: { $elemMatch: { userId: this.userId } },

Any idea why?

Might it be you are running into this issue?

Depending on the mongodb version you had before, it doesn’t like the ‘usersclaps.claps’ part anymore when mongodb was updated to 4.4.4 with Meteor 2.2


would it work if you removed this: 'usersclaps.claps': 1 ?


Thank you for sharing it. I think this problem I have. I removed `‘usersclaps.claps’: 1 and it works now.

Yes, it helped! Thank you! :slight_smile:

1 Like