我有一个基本的User
架构
var UserSchema = new Schema({
name: {
type: String,
required: true
},
password: {
type: String,
required: true
}
});
现在我要实现dual login
功能,
async.parallel([
function (cb) {
User.findOne({$and: [{name: req.body.username1}, {password: req.body.password1}]}, function (err, u) {
if (!u)
err = "User1 dose not exist";
cb(err, u)
});
},
function (cb) {
User.findOne({$and: [{name: req.body.username2}, {password: req.body.password2}]}, function (err, u) {
if (!u)
err = "User2 dose not exist";
cb(err, u)
});
}
], function (err, results) {
....
我想知道是否有简单的方法可以在一个User.find()
函数中找到这两个用户信息?
答案 0 :(得分:4)