b***@163.com
b***@163.com
  • 发布:2023-03-10 14:31
  • 更新:2024-07-02 22:21
  • 阅读:194

uniCloud支持$facet吗

分类:uniCloud

db.collection('news').aggregate([
{ "$facet": {
"Total": [
{ "$match" : { "ReleaseDate": { "$exists": true }}},
{ "$count": "Total" },
],
"Released": [
{ "$match" : {"ReleaseDate": { "$exists": true, "$nin": [""] }}},
{ "$count": "Released" }
],
"Unreleased": [
{ "$match" : {"ReleaseDate": { "$exists": true, "$in": [""] }}},
{ "$count": "Unreleased" }
]
}},
{ "$project": {
"Total": { "$arrayElemAt": ["$Total.Total", 0] },
"Released": { "$arrayElemAt": ["$Released.Released", 0] },
"Unreleased": { "$arrayElemAt": ["$Unreleased.Unreleased", 0] }
}}
])

2023-03-10 14:31 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ
limingfan

limingfan

那就是不能支持列表分页数据的同时返回总数了是吧?@DCloud_uniCloud_WYQ

要回复问题请先登录注册