2017-02-26 4 views
0

この流星アプリは、user.profile.groupという値に基づいて各ユーザーにレコードを公開する必要がありますが、フィルタリングしていないセット全体を公開しています。
私は間違って何をやっているのですか? THX公開されたドキュメントuser.profile.propに基づくフィルタ

//lib/collections.js 
MenuItemsCol = new Mongo.Collection('menuItemsCol'); 

//client/main.js 
Meteor.subscribe('menuItemsCol'); 

//server/publications.js 
MenuItemsCol.remove({app: 'abc'}); 
lib.mainMenuItems.forEach(function (item) { 
    if (item.app === 'abc') { 
    MenuItemsCol.insert(item); 
    } 
}); 

Meteor.publish('menuItemsCol', function() { 
    let menuGroup = ''; 
    if (this.userId) { 
    menuGroup = Meteor.users.findOne({_id: this.userId}).profile.menuGroup; 
    } 
    return MenuItemsCol.find({app: 'abc'}, {group: {$in: menuGroup.split('')}}, {sort: {createdAt: 1}}); 
}); 

//db.users.find(this.userId) shows 
profile" : { 
     "menuGroup" : "g" 

答えて

0

検索のための最初の引数は()は、第2のオプションで、フィルタです。あなたは3つの引数を供給している、そしてそれはあなたのフィルタであることを意味している最初の2のようになります。

return MenuItemsCol.find({app: 'abc'}, {group: {$in: menuGroup.split('')}}, {sort: {createdAt: 1}}); 

私はあなたがこの意味を考える:

return MenuItemsCol.find({ 
     app: 'abc', 
     group: {$in: menuGroup.split('')} 
    }, 
    { 
     sort: {createdAt: 1} 
    }); 
関連する問題