我正在为我的项目编写 couchbase 查询并在 1 个查询中遇到问题。以下是问题的详细信息。
我有一个名为“workflow”的存储桶,其中几乎没有文档:-
{
type = "task",
status = "Completed",
appId = "72689c67-f5d1-474a-8802-77f332144b12",
taskNo = 1
},
{
type = "task",
status = "Completed",
appId = "72689c67-f5d1-474a-8802-77f332144b12",
taskNo = 2
},
{
type = "task",
status = "New",
appId = "72689c67-f5d1-474a-8802-77f332144b12",
taskNo = 3
},
{
type = "task",
status = "New",
appId = "72689c67-f5d1-474a-8802-77f332144b12",
taskNo = 4
},
{
type = "task",
status = "New",
appId = "72689c67-f5d1-474a-8802-77f332144b12",
taskNo = 5
}
我写了一个查询:-
select status, count(*) from workflow where type="task" and appId="72689c67-f5d1-474a-8802-77f332144b12" and status!="" group by status;
结果:-
[
{
"$1": 2,
"status": "Completed"
},
{
"$1": 3,
"status": "New"
}
]
预期结果:-
[
{
"Completed": 2
},
{
"New": 3
}
]
有什么办法可以得到预期的结果?任何线索都会非常有帮助。我将免于运行不必要的 for 循环,这将在缩放期间优化我的代码。以及以下声明的任何其他替代方案?
status!=""