在Mongo API上查找比较字符串属性长度的对象



我需要找到所有用错误值创建的对象,并指出这是其中字符串的长度。

我已经尝试使用这个答案中的建议,但是Cosmos说不支持$expr和$where。

有没有可能不遍历所有对象?

与此同时,我已经能够做我需要使用这个:

aggregate(
[
{ 
"$match" : { 
}
}, 
{ 
"$redact" : { 
"$cond" : [
{ 
"$lt" : [
{ 
"$strLenCP" : { 
"$convert" : { 
"input" : "$_id", 
"to" : "string", 
"onError" : "Error occurred", 
"onNull" : "Input null"
}
}
}, 
36.0
]
}, 
"$$KEEP", 
"$$PRUNE"
]
}
}, 
{ 
"$project" : { 
"_id" : 1.0
}
}
]
);

最新更新