use of com.mongodb.AggregationOptions in project morphia by mongodb.
the class AggregationTest method testOut.
@Test
public void testOut() {
checkMinServerVersion(2.6);
getDs().save(asList(new Book("The Banquet", "Dante", 2), new Book("Divine Comedy", "Dante", 1), new Book("Eclogues", "Dante", 2), new Book("The Odyssey", "Homer", 10), new Book("Iliad", "Homer", 10)));
AggregationOptions options = builder().outputMode(AggregationOptions.OutputMode.CURSOR).build();
Iterator<Author> aggregate = getDs().createAggregation(Book.class).group("author", grouping("books", push("title"))).out(Author.class, options);
Assert.assertEquals(2, getDs().getCollection(Author.class).count());
Author author = aggregate.next();
Assert.assertEquals("Homer", author.name);
Assert.assertEquals(asList("The Odyssey", "Iliad"), author.books);
getDs().createAggregation(Book.class).group("author", grouping("books", push("title"))).out("different", Author.class);
Assert.assertEquals(2, getDb().getCollection("different").count());
}
Aggregations