如何解决Spring Mongo:将变量引用传递给StringOperators.Substr
我正在尝试将mongo投影操作转换为Spring
$project: {
strippedRecord: {
$let: {
vars: {
start: { $add: [ { $indexOfBytes: [ "$textRecord","BLABLA" ] },1 ] },end: { $strLenBytes: "$textRecord" }
},in: { $substr: [ "$textRecord","$$start",{ $subtract: [ "$$end","$$start" ] } ] }
}
}
}
在春季,
project()
.and(Let.define(Let.ExpressionVariable
.newVariable("start")
.forExpression(
ArithmeticOperators.Add.valueOf(StringOperators.IndexOfBytes.valueOf("textRecord").indexOf("BLABLA")).add(1)
),Let.ExpressionVariable
.newVariable("end")
.forExpression(
StringOperators.StrLenBytes.stringLengthOf("textRecord")
)
)
.andApply(**********)
).as("strippedRecord")
我正在尝试使用下面的表达式来计算“ ***********”部分中的相减。
StringOperators.Substr.valueOf("textRecord").substring()
但是,substring()方法仅采用“ int”。那么,如何在这里的子字符串操作中读取变量引用$$ end,$$ start?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。