How to do "substr" operation in GroupOperation as Id with spring data mongodb?

Viewed 343

How can I achieve this operation in spring data mongodb?

$group: {
  "_id": {orderDate: {"$substr": ["$localDate",0,params.getDateType]},storeId: "$storeId"},
  "date": {"$last": {"$substr": ["$localDate",0,params.getDateType]}
},

So far I have tried this.

GroupOperation groupOperation = Aggregation.group(String.valueOf(new BasicDBObject("orderDate",
        StringOperators.Substr.valueOf("localDate").substring(0,dateType))))
    .last(String.valueOf(new BasicDBObject("orderDate",
        StringOperators.Substr.valueOf("localDate").substring(0,dateType)))).as("date")

Thanks in Advance.

0 Answers
Related