如何在投影中应用嵌套字符串运算符?
How can i apply nested string operators in projection?
我需要使用执行此投影的聚合器框架创建实现:
{ $project : { code: $toUpper : { $substr : ["$vendor", 0, 2 ] } } }
到目前为止,我还没有找到一种方法来使用 Spring 来表达 $substr
和 $toUpper
操作的连接。我已经尝试过这种结构和其他类似的变体,但我没有成功。
ProjectionOperation projection = project()
.and("vendor").substring(0, 2).toLower().as("code");
谁能告诉我如何做到这一点?
方法如下:
project()
.and(ToLower.lowerValueOf(SubstrCP.valueOf("vendor").substringCP(0, 2)))
.as("code")
我需要使用执行此投影的聚合器框架创建实现:
{ $project : { code: $toUpper : { $substr : ["$vendor", 0, 2 ] } } }
到目前为止,我还没有找到一种方法来使用 Spring 来表达 $substr
和 $toUpper
操作的连接。我已经尝试过这种结构和其他类似的变体,但我没有成功。
ProjectionOperation projection = project()
.and("vendor").substring(0, 2).toLower().as("code");
谁能告诉我如何做到这一点?
方法如下:
project()
.and(ToLower.lowerValueOf(SubstrCP.valueOf("vendor").substringCP(0, 2)))
.as("code")