문제

ID "ID", Integer 유형이있는 데이터베이스가 있습니다.나는 사용하고있다 :

records= config.gsupei1Collection.Find (). 정렬 ([( "ID", Pymongo.descendo.descendo))])

커서를 가져오고 를 사용합니다.

레코드= 기록 [0]

가장 큰 ID 레코드를 얻으려면

나는 '기록'을 얻은 후에 궁금해하고 있으며, record.next (), record.prev ()를 사용하여 레코드에 이웃 인 레코드를 사용할 수 있습니까?어떤 문서도 찾을 수 없습니다.

도움이 되었습니까?

해결책

You can loop the records. Record is an actual document (a dict), not an iterator, but the result is.

You can do something like this:

for i, d in enumerate(records):
    print i, d

Or if you want to use the returned records as an iterator, you can do something like:

n = records.next()

Or for forward compatibility:

n = next(records)

Records is an iterator. Every time you see something that you can loop, it's an iterable, and you can just call next() and rewind() on it. Be careful though, calling rewind() will reissue the same query to the database server.

FYI, the easiest way to see what type something is is to prototype your program in the interpreter, then you can do >> help(records) and see the pydocs.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top