All project-match-sort- group-count
[{
$project: {
OrderId: 1,
OrderCode_Root: '$OrderCode',
OrderCode: {
$toLower: '$OrderCode'
},
ObjId: 1,
ObjContract: 1,
OrderDetails: 1,
Vouchers: 1,
LastUpdatedDate: {
$toDate: {
$toLong: '$LastUpdatedDate'
}
},
Vou_SerCode_ListInt: '$Vouchers.Apply.ServiceCode'
}
}, {
$match: {
ObjContract: {
$eq: null,
$ne: -100
},
OrderId: {
$gt: 0,
$gte: 0,
$lt: 100000,
$lte: 100000
},
'Vouchers.Apply.ServiceCode': 321,
'OrderDetails.0.Address.LocationId': 8,
'OrderDetails.0': {
$exists: true
},
'Vouchers.Apply.1': {
$exists: true
},
OrderDetails: {
$exists: true,
$ne: null
},
ObjId: {
$in: [
0,
1,
null
]
},
$and: [
{
$or: [
{
OrderId: {
$gt: 0
}
},
{
OrderId: {
$gt: 0
}
}
],
OrderId: {
$gt: 0
}
}
]
}
}, {
$sort: {
OrderId: -1,
ObjId: -1
}
}, {
$limit: 100
}, {
$skip: 50
}]
0 Nhận xét