tags:

views:

21

answers:

2

Hello,

I'm playing around with mongodb (documentation isn't very complete):

tmpQuery = collection.find({"title_full": "kdsljfklsadfklj"})
print tmpQuery[0]['title_full']

That just echo's "no such item for Cursor instance", what is an if statement to determine if the variable tmpQuery has a valid result set and not empty?

A: 

Can tmpQuery.hasNext() help?

kaloyan
unfortunately no, it gives the error "'Cursor' object has no attribute 'hasNext'"
Joe
How about `cursor.count()`?
kaloyan
+1  A: 

oh geez, issue solved with:

tmpQuery.count()
Joe