javamongodbjacksonmongo-jackson-mapper

What is the JacksonDB equivalent of db.collection.find({},{"fieldName":1})?


I am new to Jackson DB. Now I know that to get the entire document list of a collection using Jackson we need to do :

COllectionClass.coll.find().toArray();

which is Jackson DB equivalent to the mongodb command :

db.collection.find()

So What is the Jackson DB equivalent of say :

db.collection.find({},{"fieldName":1, "_id":0}) 

Solution

  • As given here, This might be helpful to you. (not tested)

    coll.find(DBQuery.is(),//add your criteria for search here
        DBProjection.include("fieldName")).toArray();