Mongodb node.js $out with aggregation only working if calling toArray()

后端 未结 2 981
遇见更好的自我
遇见更好的自我 2021-02-20 07:31

Saving an aggregation query using \"mongodb\": \"^3.0.6\" as result with the $out operator is only working when calling .toArray().

2条回答
  •  时光说笑
    2021-02-20 07:38

    Because the Aggregation operation returns a cursor, not the results. In order to return all the documents from the cursor, we need to use toArray method.

提交回复
热议问题