2012-03-26 3 views

답변

14

Ruby API에는 정확히 원하는 것을 수행하는 rewind! 메서드가 있습니다.

Python APIcursor.rewind() 방법을 사용합니다.

PHP APIcursor.rewind() 방법을 사용합니다.

그러나 Java API 나 C++ API에는 되감기 메소드가 없습니다. 모두는 official API page에서 찾을 수 있습니다.

+0

알아두면 좋지만 Ruby를 사용하지는 않습니다. – mark

+0

@mark : 되감기가있는 파이썬 API에 대한 링크를 추가했습니다. – brice

+0

두 가지 API 중 하나를 모르지만 둘 다 드라이버 트릭인지 궁금합니다. MongoDB가 기본적으로 지원하는 것입니까? –

0

pymongo의 커서가 .rewind() 인 경우 sample code from previous question with answer that apply을 참조 할 수 있습니다.

기본 몽고 쉘 API를, 그러나, 이러한 방법을 제공하지 않습니다, method help() on DBQuery object prototype. 참조 : 다음 foreach($cursorData as $data) 언제든지 실행 $cursor->reset();

:

> db.collection.find().help() 
find() modifiers 
     .sort({...}) 
     .limit(n) 
     .skip(n) 
     .count() - total # of objects matching query, ignores skip,limit 
     .size() - total # of objects cursor would return, honors skip,limit 
     .explain([verbose]) 
     .hint(...) 
     .showDiskLoc() - adds a $diskLoc field to each returned object 

Cursor methods 
     .forEach(func) 
     .map(func) 
     .hasNext() 
     .next() 
1

당신은 PHP를 들어 cursor.reset();

사용할 수 있습니다 재설정 후.

관련 문제