Monday, 9 September 2013

Max/Min value(without field name) in mongodb with java

Max/Min value(without field name) in mongodb with java

I am using the below mentioned MongoDB query in Java to find the maximun
value of field "price":
DBCursor cursor = coll.find(query,fields).sort(new
BasicDBObject("price",1)).limit(1);
"fields" argument passing to coll.find function here is having the "price"
field only.
So I am getting the output in the form:
{ "price" : value}
Is there any way to get value only in the output without the field name
and braces etc, so that it can be assigned to a variable or returned to
the calling function etc.
Or if there is any other query or mechanism available that I can use for
the same purpose.
Pls suggest..
Thanks & Regards

No comments:

Post a Comment