Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想从accounts ui meteor软件包访问用户集合中存在的所有用户电子邮件列表_Meteor - Fatal编程技术网

我想从accounts ui meteor软件包访问用户集合中存在的所有用户电子邮件列表

我想从accounts ui meteor软件包访问用户集合中存在的所有用户电子邮件列表,meteor,Meteor,var user=Meteor.users.find().fetch; 这会按预期返回一个值,但如何仅检索用户集合中所有用户的email.address字段?以下是一个可能的解决方案: var emails=..chain(Meteor.users.find().fetch()) .pulk(“电子邮件”) .flatte() .pluck('地址') .value(); 这将为您提供一个简单的电子邮件列表,但是请注意,在meteor中,用户可以有多个电子邮件地址(如果您的UI支持的话)。在上

var user=Meteor.users.find().fetch;
这会按预期返回一个值,但如何仅检索用户集合中所有用户的email.address字段?

以下是一个可能的解决方案:

var emails=..chain(Meteor.users.find().fetch())
.pulk(“电子邮件”)
.flatte()
.pluck('地址')
.value();

这将为您提供一个简单的电子邮件列表,但是请注意,在meteor中,用户可以有多个电子邮件地址(如果您的UI支持的话)。在上面的例子中,所有这些都将被返回。

一个简单的答案是:

db.users.find({},{ "emails.address" : 1});
这将产生如下结果:

{ "_id" : "caGts2niaDyS6TbYJ", "emails" : [ { "address" : "asoldfj@bigglie.com" } ] }
{ "_id" : "g5oPp4ReDCwuuW8yn", "emails" : [ { "address" : "blogsalfd@sag.com" } ] }
{ "_id" : "ge9YyFehBMN7q3xQ9", "emails" : [ { "address" : "hag@toldyou.com" } ] }
如果您不想要_id:

db.users.find({},{ "emails.address" : 1, "_id": 0});
产生:

{ "emails" : [ { "address" : "asoldfj@bigglie.com" } ] }
{ "emails" : [ { "address" : "blogsalfd@sag.com" } ] }
{ "emails" : [ { "address" : "hag@toldyou.com" } ] }
David Weldon正确地指出,电子邮件地址字段实际上是一个数组,因此您可以在该字段中保存多封电子邮件

但是,如果您知道它只包含一封电子邮件,您可以使用它并搜索它,而不必担心数组。例如,以下内容将生成一条记录:

Meteor.users.findOne({ "emails.address" : 'asoldfj@bigglie.com' });