Projeto como documento aninhado no mongo da primavera
Estou procurando um tradutor para alterar isso:
getCollection('migrate').aggregate([
{ "$project": {
"Contrat": {"Field1":"$Field1", "Field2":"$Field2"},
"Formule": {"Field3":"$Field3", "Field4":"$Field4"}
}},
{ "$project": {
"Contrats": {"Contrat":"$Contrat", "Formule":"$Formule"}
}}
])
à estrutura de agregação MongoJava. Algo como
AggregationOperation project = Aggregation.project("Field1,Field2"); // while naming it "Contrat"
AggregationOperation project2 = Aggregation.project("Field3,Fiel4"); // while naming it Formule
AggregationOperation project3 = Aggregation.project("Contrat,Formule"); // while naming it " Contrats"
AggregationOperation out = Aggregation.out("test");
Aggregation aggregation = Aggregation.newAggregation(project, project2, project3, out);
mongoTemplate.aggregate(aggregation, "<nameOfInitialCollection>", Class.class);
Não consigo encontrar minhas respostas na documentação, que acho muito ruim, ou posso estar muito perdida (| burra).
Desde já agradeç