rubenqba
rubenqba

Reputation: 38

How can i apply nested string operators in projection?

I need to create an implementation using aggregator framework that executes this projection:

{ $project : { code: $toUpper : { $substr : ["$vendor", 0, 2 ] } } } 

So far I have not found a way to express the concatenation of the $substr and $toUpper operation using Spring. I have tried with this construction and other similar variants, but I have not succeeded.

ProjectionOperation projection = project()
                .and("vendor").substring(0, 2).toLower().as("code");

Can anyone give me an idea of how to do this?

Upvotes: 1

Views: 80

Answers (1)

prasad_
prasad_

Reputation: 14287

Here is the way to do it:

project()
    .and(ToLower.lowerValueOf(SubstrCP.valueOf("vendor").substringCP(0, 2)))
    .as("code")

Upvotes: 1

Related Questions