Ich versuche, Aggregates.project zu verwenden, um das Array in meine Dokumente zu schneiden. Meine Dokumente ist wiewie mongodb java-driver zu verwenden Projections.slice
{
"date":"",
"stype_0":[1,2,3,4]
}
und mein Code in Java aussieht, ist:
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))))
schließlich bekomme ich Fehler
First argument to $slice must be an array, but is of type: int
Ich denke, Das ist, weil das erste Element in stype_0 ist int, aber ich weiß wirklich nicht warum? Danke vielmals!
oh, ich bin so unvorsichtig, vielen Dank – CXWorks