mongoClient = new MongoClient(new MongoClientURI(uri));
|
// Set the desired Database
|
DB mDB = mongoClient.getDB(db);
|
DBCollection collection = mDB.getCollection("objectstore");
|
BasicDBObject mQuery = new BasicDBObject("data.vars",new BasicDBObject("$exists",true));
|
// create our pipeline operations, first with the $match
|
DBObject match = new BasicDBObject("$match", new BasicDBObject("data.vars", new BasicDBObject("$exists",true)));
|
|
// build the $projection operation
|
DBObject pFields = new BasicDBObject("_id", 1);
|
pFields.put("unitValueMid","$data.vars.unitValueMid");
|
DBObject project = new BasicDBObject("$project", pFields );
|
|
// run aggregation
|
List<DBObject> pipeline = Arrays.asList(match, project);
|
AggregationOutput output = collection.aggregate(pipeline);
|
When i run my spec test call this code, it throws the compiler errors,
[error] /Users/dylan/projects/connectors/app/io/point/storageconnectors/MongoDBConnector.java:754: error: method aggregate in class DBCollection cannot be applied to given types;
|
[error] AggregationOutput output = collection.aggregate(pipeline);
|
[error] ^
|
[error] required: DBObject,DBObject[]
|
[error] found: List<DBObject>
|
[error] reason: actual argument List<DBObject> cannot be converted to DBObject by method invocation conversion
|
[error] 1 error
|
[error] (compile:compile) javac returned nonzero exit code
|
[error] Total time: 4 s, completed Jul 23, 2014 3:36:33 PM
|
|