架构:
var instaSchema = mongoose.Schema({
Active: {
type: Number,
default: 1
},
Actionusers: [{
Actiontype: {
type: Number,
},
Iscompleted: {
type: Number,
default: 0,
},
status: {
type: Boolean,
default: false,
},
}]
})
我同样有数据:
_id: 5956020e4f605403d85f24d5,
Active: 1,
Actionusers: [{
Actiontype: 1,
_id: 5957420f5decd01de09deb3a,
status: true,
Iscompleted: 1,
},
{
Actiontype: 1,
_id: 5957420f5decd01de09deb3f,
status: true,
Iscompleted: 1,
},
{
Actiontype: 1,
_id: 5957420f5decd01de09deb44,
status: true,
Iscompleted: 0,
},
{
Actiontype: 1,
_id: 5957420f5decd01de09deb49,
status: true,
Iscompleted: 0,
},
{
Actiontype: 1,
_id: 5957420f5decd01de09deb4e,
status: true,
Iscompleted: 0,
},
]
我想要status: true
和Iscompleted: 0
的对象列表
我正在使用以下查询,但无法获得只需要数据..
Model.find({ _id: "5956020e4f605403d85f24d5" },
{ Actionusers: { $elemMatch: { Iscompleted: 1, status: true } } }).select({Actionusers:1})