when I tried to print the value of x and y, x is printing fine(as
expected ), but the value of y is nothing.
Also I wrote a stored procedure in which the function just returned,
db.collection.find().limit(2)
When I called db.eval("functionname()") from my application(in Java),
the output was,
{ "value" : "DBQuery: history.messages -> undefined"}
Though when stored JS function returns, db.collection.findOne() then
it is running fine
Some one please explain me why there is a difference.
Findone returns a single document and find returns a cursor, which you could convert to an array.
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
I tried this and and I am getting the expected result,
my only question is why is this difference existing between
cursor(find()) and single document(findOne()). why I am not able to
store the cursor in a variable and later print the same value using
the variable.
On Nov 21, 8:36 am, Scott Hernandez <scotthernan...@gmail.com> wrote:
> Findone returns a single document and find returns a cursor, which you
> could convert to an array.
You should convert the cursor to actual documents by calling toArray()
like this:
var docs = db.coll.find().toArray();
http://www.mongodb.org/display/DOCS/Queries+and+Cursors
DBCursor cursor =
mongo.getCollection("collection_name").find().limit(2)
while(cursor.hasNext())
print(cursor.next());
Is it that everytime when cursor.next() is done, it goes to the server
and ask for the "next"
How then latency issues are handles if the implementation is like
above.
Please clarify where I am thinking wrong.. ??
> x = db.messages.find().limit(2)
{ "_id" : ObjectId("4ec1172944ae943434c16939"), .................. }
> x
>
> x.hasNext()
false
>
so how can you tell that my query hasn't run, if it is, then why it is
displaying me the expected output ?
DBCursor cursor =
mongo.getCollection("collection_name").find().limit(2)
I am sure that cursor is not iterated. So, is it the case that when I
do cursor.next() it goes to the mongo server.
Or, every Object(in the result cursor) is returned to the Application
server and simply we do a cursor.next() and thus dont required to go
to the mongo server ??