【发布时间】:2021-02-06 21:13:12
【问题描述】:
我的项目中有一个 UserModel,它在下面的架构中具有 mobile_number 属性
const userSchema = new Schema(
{
firstname: {
type: String,
text: true,
maxlength: 50
},
lastname: {
type: String,
text: true,
maxlength: 50
},
username: {
type: String,
text: true,
maxlength: 50
},
last_login: {
type: Date
},
dob: {
type: Date
},
mobile_number: [{
type: String,
text: true,
maxlength: 50
}]
})
我还有一组手机号码 ['08099999394', '0809992224', '08176674394']
使用这个手机号码数组,如何在不运行 for 循环的情况下获取在数组中拥有手机号码 (user.mobile_number) 的用户列表?
【问题讨论】:
标签: mongoose mongodb-query mongoose-populate