Following is the entity class for "Projects".I need to fetch the field "title" and "projectName" of all the documents with projectName as "xyz".The field name "title" in the retrieved documents should be renamed as "renamedTitle" while retrieving.
@Document (collection = "projectCollection")
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Project {
@Id
private String projectId;
private String projectName;
private String title;
}
if the document collection is:
{"_id":"1","projectName":"alpha","title":"start"},
{"_id":"2","projectName":"beta","title":"mid"},
{"_id":"3","projectName":"xyz","title":"last"}
The output expected is:
{"projectName":"xyz","renamedTitle":"last"}