Query help

9 views
Skip to first unread message

Shervin Asgari

unread,
Oct 14, 2014, 5:55:01 AM10/14/14
to mongo-jack...@googlegroups.com
Hi.

I am quite new to MongoDB and MongoJack.

I have the follwing collection (test example)

pdf [
     -id : "92837ALKJ2397"
     players: [
          playerId: "293829378"
          items = [
               //Here is some stuff
          ]
     ]
]

I would like to create a query that uses the pdf id and playerId to get the items
How can I do this?

Right now I do this

pbfCollection.findOneById(pbfId);

PBF pbf = pbfCollection.findOneById(pbfId);

        List<Items> items = pbf.getPlayers().stream()
                .filter(p -> p.getPlayerId().equals(playerId))
                .findFirst()
                .orElseThrow(PlayerAction::cannotFindItem)
                    .getItems()

I would like to create a simple query that takes pdfId and playerId as parameter and retrieves my Items list.
Reply all
Reply to author
Forward
0 new messages