2012-03-26 12 views

risposta

14

Il ha il metodo rewind! che fa esattamente ciò che si desidera.

Il Python API ha anche il metodo cursor.rewind().

Il PHP API ha anche il metodo cursor.rewind().

Tuttavia, né le API Java né C++ hanno il metodo di riavvolgimento. Tutto può essere trovato da official API page.

+0

Buono a sapersi, ma non sto usando Ruby. – mark

+0

@mark: aggiunto link a python api che ha riavvolto. – brice

+0

Non conosco nessuna di queste due API ma mi chiedo se sono entrambi solo trucchetti dei driver - È qualcosa che è supportato da MongoDB in modo nativo –

0

Il cursore in pymongo ha il metodo .rewind(), è possibile fare riferimento a sample code from previous question with answer that apply.

shell mongo API native, tuttavia, non fornisce tale metodo, vedere method help() on DBQuery object prototype.:

> 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

È possibile utilizzare cursor.reset();

Per PHP: $cursor->reset();

quindi eseguire il foreach($cursorData as $data) qualsiasi momento dopo il ripristino.

Problemi correlati