【发布时间】:2015-05-14 23:42:03
【问题描述】:
我正在使用 Mongoose 查询我的用户架构,其中包含:
var usersSchema = new Schema(
{
email : String,
regId : { type : String , default : '' },
lastName : { type : String , default : '' },
...
});
我需要为我拥有的电子邮件数组获取getId 属性值。目前我正在尝试做:
db.model('users').find( { email : { $in : arrUsers } }, { regId : true, _id : false }, function (err, res) { ... }
我收到这个数组:[{ regId : "..." }, { regId : "..." }]。
我想收到什么:{ "...", "..." }。
有没有简单的方法来做到这一点?非常感谢!!!
编辑:我有兴趣在数据库端执行 for 循环...
【问题讨论】:
标签: javascript node.js mongodb mongoose