How can I get the length of characters from a field that is nested in another field? and it is in an array. eg:
{
"_id" : ObjectId("687e1db"),
"content" : {
"ods" : "1102223000241",
"startDate" : ISODate("2017-05-11T12:00:00Z"),
"classes" : [
{
"driveNumber" : "9999078900007091",
"number" : "00107605829357",
"sId" : "0000000005009593"
}
],
"user" : "SoftLogic",
},
"level" : 2
}
and I want to get a sample in the content.classes.number
, where there are more than 16 characters in the field.
when making a request I was guided by String field value length in mongoDB
Either this request is not suitable for this situation, or I am doing something wrong.
db.Basis.find({
"content.classes.number": { "$exists": true },
"$expr": { "$gt": [ { "$strLenCP": "$content.classes.number" }, 16 ] }})
I get the error: https://gyazo.com/d2849406d36364de94d6ea89eff1c2b6
I tried not only such options.
UPD mongo version 3.4.3