0
我想使用Aggregates.project切片我的文檔中的數組。 我的文檔就像如何使用mongodb的java驅動程序Projections.slice
{
"date":"",
"stype_0":[1,2,3,4]
}
在mongochef
和我的Java代碼:
Aggregates.project(Projections.fields(
Projections.slice("stype_0", pst-1, pen-pst),Projections.slice("stype_1", pst-1, pen-pst),
Projections.slice("stype_2", pst-1, pen-pst),Projections.slice("stype_3", pst-1, pen-pst))))
最後我得到錯誤
First argument to $slice must be an array, but is of type: int
我猜這是因爲stype_0中的第一個元素是int,但我真的不知道爲什麼?非常感謝!
哦!我太粗心了,非常感謝你 – CXWorks