Package org.springframework.data.mongodb.core.aggregation

Examples of org.springframework.data.mongodb.core.aggregation.Aggregation$NoOpAggregationOperationContext


  @Test
  public void shouldAggregate() {

    createTagDocuments();

    Aggregation agg = newAggregation( //
        project("tags"), //
        unwind("tags"), //
        group("tags") //
            .count().as("n"), //
        project("n") //
View Full Code Here


  }

  @Test
  public void shouldAggregateEmptyCollection() {

    Aggregation aggregation = newAggregation(//
        project("tags"), //
        unwind("tags"), //
        group("tags") //
            .count().as("n"), //
        project("n") //
View Full Code Here

  @Test
  public void shouldDetectResultMismatch() {

    createTagDocuments();

    Aggregation aggregation = newAggregation( //
        project("tags"), //
        unwind("tags"), //
        group("tags") //
            .count().as("count"), // count field not present
        limit(2) //
View Full Code Here

    mongoTemplate.save(user1);
    mongoTemplate.save(user2);
    mongoTemplate.save(user3);

    Aggregation agg = newAggregation( //
        project("id", "msgs"), //
        unwind("msgs"), //
        match(where("msgs.createDate").gt(now.minusDays(1).toDate())), //
        group("id").push("msgs").as("msgs") //
    );
View Full Code Here

    mongoTemplate.save(new Person("p4_first", "p4_last", 15));

    List<DBObject> personsWithAge25 = mongoTemplate.find(Query.query(where("age").is(25)), DBObject.class,
        mongoTemplate.getCollectionName(Person.class));

    Aggregation agg = newAggregation(group("age").push(Aggregation.ROOT).as("users"));
    AggregationResults<DBObject> result = mongoTemplate.aggregate(agg, Person.class, DBObject.class);

    assertThat(result.getMappedResults(), hasSize(3));
    DBObject o = (DBObject) result.getMappedResults().get(2);
View Full Code Here

    mongoTemplate.save(new Reservation("0123", "42", 100));
    mongoTemplate.save(new Reservation("0360", "43", 200));
    mongoTemplate.save(new Reservation("0360", "44", 300));

    Aggregation agg = newAggregation( //
        match(where("hotelCode").is("0360")), //
        sort(Direction.DESC, "confirmationNumber", "timestamp"), //
        group("confirmationNumber") //
            .first("timestamp").as("timestamp") //
            .first(Aggregation.ROOT).as("reservationImage") //
View Full Code Here

        .and("dateValue").extractDayOfWeek().as("dayOfWeek") //
        .andExpression("dateValue + 86400000").extractDayOfYear().as("dayOfYearPlus1Day") //
        .andExpression("dateValue + 86400000").project("dayOfYear").as("dayOfYearPlus1DayManually") //
    ;

    Aggregation agg = newAggregation(dateProjection);
    AggregationResults<DBObject> result = mongoTemplate.aggregate(agg, ObjectWithDate.class, DBObject.class);

    assertThat(result.getMappedResults(), hasSize(1));
    DBObject dbo = result.getMappedResults().get(0);
View Full Code Here

    items.add( new Item(2, 42.0, "Item #2") );
    order.setItems(items);
    repo.save(order);

    // when
    Aggregation agg =  newAggregation(
        project("items").andExclude("_id")
        );
    AggregationResults<Order> result =  template.aggregate(agg, Order.class, Order.class);
   
   
View Full Code Here

    items.add( new Item(2, 42.0, "Item #2") );
    order.setItems(items);
    repo.save(order);

    // when
    Aggregation agg =  newAggregation(
        project("items").andExclude("_id")
        );
    AggregationResults<Order> result =  template.aggregate(agg, Order.class, Order.class);
   
   
View Full Code Here

TOP

Related Classes of org.springframework.data.mongodb.core.aggregation.Aggregation$NoOpAggregationOperationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.