Meteor.users の電子メール アドレスを表す一連のレコードを公開するための公開/購読コードの作成に関するヘルプを探しています。publish メソッドは別のセットに基づいて新しいセットを作成して返す必要があるため、これは私にとって注意が必要です...
1 に答える
0
パブリケーション/サブスクリプションでこれを行いたくありません。Meteor Methodを作成することをお勧めします。クライアントから呼び出すことができ、サーバー上で (サーバーにはすべてにアクセスする権限があるため)、すべての電子メールを収集し、クライアントに送り返します。その後、クライアントに残りの部分へのアクセスを許可する必要はありません。
// On the server
Meteor.methods({
userEmails: function() {
users = [];
// For each user, add the user's address to the array
Meteor.users.forEach(function(user) {
users.push(user.emails[0].address);
});
// Return the array of emails
return users;
}
});
次に、クライアントからそれを呼び出すことができます:
// On the client
Meteor.call('userEmails', function (error, result) {
// When the server returns the list of emails, this will run
if (error) {
// There was an error
} else {
// Do something with the result, which is the array of emails
}
});
于 2013-05-22T18:47:31.130 に答える