字段的数据类型是String.我想获取字段名称的字符长度大于40的数据.
我尝试了这些查询但返回错误.1.
db.usercollection.find(
{$where: "(this.name.length > 40)"}
).limit(2);
output :error: {
"$err" : "TypeError: Cannot read property 'length' of undefined near '40)' ",
"code" : 16722
}
Run Code Online (Sandbox Code Playgroud)
这是在2.4.9但我的版本是2.6.5