mirror of
https://github.com/OtusTeam/Spring.git
synced 2026-05-30 10:50:42 +00:00
mongo-db-example updated
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
1695056720328:m
|
||||
1695056755656:exit
|
||||
1695062261073:m
|
||||
|
||||
+1
-2
@@ -24,7 +24,7 @@ import static org.springframework.data.mongodb.core.query.Criteria.where;
|
||||
public class StudentRepositoryCustomImpl implements StudentRepositoryCustom {
|
||||
|
||||
@Data
|
||||
private class ArraySizeProjection {
|
||||
private static class ArraySizeProjection {
|
||||
private int size;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ public class StudentRepositoryCustomImpl implements StudentRepositoryCustom {
|
||||
, project().and("experience._id").as("_id").and("experience.name").as("name")
|
||||
);
|
||||
|
||||
Document rawResults = mongoTemplate.aggregate(aggregation, Student.class, Knowledge.class).getRawResults();
|
||||
return mongoTemplate.aggregate(aggregation, Student.class, Knowledge.class).getMappedResults();
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -21,7 +21,8 @@ public class TeacherRepositoryCustomImpl implements TeacherRepositoryCustom {
|
||||
val aggregation = newAggregation(
|
||||
match(Criteria.where("id").is(teacherId))
|
||||
, unwind("experience")
|
||||
, project().andExclude("_id").and("experience.id").as("_id").and("experience.name").as("name")
|
||||
, project().andExclude("_id").and("experience.id").as("_id")
|
||||
.and("experience.name").as("name")
|
||||
);
|
||||
return mongoTemplate.aggregate(aggregation, Teacher.class, Knowledge.class).getMappedResults();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user