云数据库文档不严谨啊,发现了好多处
新功能,让新手如何适应啊
毕竟是跟着例子走呢
1、Aggregate.bucket(object: Object): Aggregate
output: {
count: $.sum(1),
...
<outputN>: <accumulator expr>
}
但在官方程序例中,却写成
db.collection('items').aggregate()
.bucket({
groupBy: '$price',
boundaries: [0, 50, 100],
default: 'other',
output: {
count: $.sum(),
ids: $.push('$_id')
}
})
.end()
返回结果如下:
[
{
"_id": 0,
"count": 2,
"ids": [
"1",
"3"
]
},
{
"_id": 50,
"count": 2,
"ids": [
"2",
"4"
]
},
{
"_id": "other",
"count": 22,
"ids": [
"5"
]
}
]
敢问最后是如何计算count成22的呢? 明明只有1个啊
2、Aggregate.bucket(object: Object): Aggregate
output: {
count: $.sum(1),
...
<outputN>: <accumulator expr>
}
但在官方程序例中,却写成
db.collection('items').aggregate()
.bucket({
groupBy: '$price',
boundaries: [0, 50, 100],
default: 'other',
output: {
count: $.sum(),
ids: $.push('$_id')
}
})
.end()
返回结果如下:
[
{
"_id": 0,
"count": 2,
"ids": [
"1",
"3"
]
},
{
"_id": 50,
"count": 2,
"ids": [
"2",
"4"
]
},
{
"_id": "other",
"count": 22,
"ids": [
"5"
]
}
]
问题跟前面是一样的,我想知道错误的文档是怎么复制粘贴的呢(o(* ̄︶ ̄*)o)
3、 Aggregate.bucketAuto(object: Object): Aggregate
db.collection('items').aggregate()
.bucket({
groupBy: '$price',
buckets: 3,
})
.end()
为什么例子的API变成了bucket呢,这是不对的,需要改成bucketAuto
4、其他还在学习中,拜托再认真核对下吧,谢谢!!!