MongoDB $projection with Java

61 views
Skip to first unread message

Willy B

unread,
Feb 8, 2014, 6:32:58 AM2/8/14
to mongod...@googlegroups.com
Hi,
I would like to execute a query with projection via Java. I have not found a usefull tutorial which explain how to do it. Does anyone has a link or could just show me how it works?
This i how my query(it works in the MongoDB shell) looks like:
db.collection.find({"Workbook.Worksheet.Table.Row.Cell.Data": "value"},{"Workbook.Worksheet.$": 1})
thanks for the help!

Asya Kamsky

unread,
Feb 8, 2014, 9:35:37 PM2/8/14
to mongodb-user
http://api.mongodb.org/java/current/com/mongodb/DBCollection.html#find(com.mongodb.DBObject,
com.mongodb.DBObject) has a small example.

You can see another example in section 1.3 on this page:
http://www.mkyong.com/mongodb/java-mongodb-query-document/

Basically you just want to create a second argument to find, same as
in the shell.

Asya
> --
> --
> 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
> See also the IRC channel -- freenode.net#mongodb
>
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Willy B

unread,
Feb 9, 2014, 5:56:08 AM2/9/14
to mongod...@googlegroups.com
That worked!
Thanks
Reply all
Reply to author
Forward
0 new messages