Projections in MongoDB #205

ufasoli opened this Issue Jul 30, 2012 · 4 comments

3 participants


It would be great if the MongoDBQuery could support projections as the HibernateQuery does as explained in this post

According to the Mongo offcial documentation much better performances can be achieved when selecting only relevant fields in a query MongoDB Documentation (Optimization # 3: Select only relevant fields)

Best regards

Ulises Fasoli

Querydsl member

Projections can now be used via the overloaded list, singleResult, uniqueResult and listResults methods. The projection type is the same as for the other methods to be consistent with previous Mongodb query behaviour.

e.g. User with only firstName and lastName mapped

User u = query.where(user.firstName.eq("Jaakko")).singleResult(user.firstName, user.lastName);
Querydsl member

Released in 3.0.0.BETA1

@timowest timowest closed this Jan 13, 2013

Does this support nested projections? For example, a single field from an array property?


I couldn't find an example that illustrates this use case. Am I overlooking something? Thanks!

@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment