Is it possible to iterate a mongo cursor twice?

前端 未结 3 1853
谎友^
谎友^ 2021-01-17 09:48

In other words, is there a way to rewind it to the beginning?

EDIT

I am using mongo shell and pymongo.

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 10:15

    You can use cursor.reset();

    For PHP : $cursor->reset();

    then run your foreach($cursorData as $data) any time after resetting.

提交回复
热议问题