Permalink
Browse files

Step 10.7: Add search pattern to the publication

  • Loading branch information...
dotansimha authored and darkbasic committed Jan 24, 2017
1 parent 8c8dfd5 commit 5ff94ff2aaac1db46637660b7131abcebdc01acc
Showing with 18 additions and 5 deletions.
  1. +18 −5 api/server/publications.ts
View
@@ -3,16 +3,29 @@ import { Users } from './collections/users';
import { Messages } from './collections/messages';
import { Chats } from './collections/chats';
Meteor.publish('users', function(): Mongo.Cursor<User> {
Meteor.publishComposite('users', function(
pattern: string
): PublishCompositeConfig<User> {
if (!this.userId) {
return;
}
return Users.collection.find({}, {
fields: {
profile: 1
let selector = {};
if (pattern) {
selector = {
'profile.name': { $regex: pattern, $options: 'i' }
};
}
return {
find: () => {
return Users.collection.find(selector, {
fields: { profile: 1 },
limit: 15
});
}
});
};
});
Meteor.publish('messages', function(

0 comments on commit 5ff94ff

Please sign in to comment.