Package com.allanbank.mongodb.builder

Provides domain classes and builders for queries and the common MongoDB commands.

See: Description

Package com.allanbank.mongodb.builder Description

Provides domain classes and builders for queries and the common MongoDB commands.

Usage

To construct a query using the builder use the static methods of the QueryBuilder class and then add conditions for fields. As an example:

 

 import static com.allanbank.mongodb.builder.QueryBuilder.and
 import static com.allanbank.mongodb.builder.QueryBuilder.or
 import static com.allanbank.mongodb.builder.QueryBuilder.not
 import static com.allanbank.mongodb.builder.QueryBuilder.where

 Document query =
           or(
              where("f").greaterThan(23).lessThan(42).and("g").lessThan(3),
              and(
                where("f").greaterThanOrEqualTo(42),
                not( where("g").lessThan(3) )
              )
           );
 
 

Each of the commands classes is immutable but has an inner static Builder class that can be used to construct the command object.

For Example:


 GroupBy.Builder builder = new GroupBy.Builder();
 builder.setKeys(Collections.singletonSet("key"));

 GroupBy command = builder.build();
 

Copyright ©:
2012-2013, Allanbank Consulting, Inc., All Rights Reserved

Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.