Meteor.users.find not support '$' on server side?

I try to publish the users exclude current one.

// ./server/main.js
Meteor.publish(‘otherUsers’, function(){
Meteor.users.find({_id: { $ne: this.userId } });

// ./client/main.js

But I still get all user in the collection.
And if I did the query in client,

// ./client/main.js
Meteor.users.find({_id: {$ne: Meteor.userId()}}).fetch();

Meteor gave me the users that exclude the current.

How could I fix this?

This is because the current user including his profile is being auto-published and Meteor mixes both publications in the client.

BTW: Are you sure you really want to do this? You’re exposing sensitive data this way. I would at least limit the fields for the pub.

Thanks for notice,

But I try

Meteor.publish(‘otherUsers’, function(){
Meteor.users.find({}, {profile: 1});


Meteor.publish(‘otherUsers’, function(){
Meteor.users.find({}, {fields: {profile: 1}});

Meteor also return full user message for me, and I still figuring out why…

The second version should be correct. Have you removed the autopublish package?

What you are seeing is the mergebox in action. Meteor pub/sub makes sure that subscriptions to the same collection are merged on the client.

As a previous poster already stated, the current user is always published, so if you have a secondary publication the current user will always be merged into it on the client.

The easiest way to deal with this would be to filter out the current user in the helper providing your template with the cursor for the collection.