I need to get the length of a string value in MongoDB using aggregation functions.
he works in
db.collection_name.find({"$where":"this.app_name.length===12"})
but when implanted in
db.collection_name.aggregate({$match: {"$where":"this.app_name.length===12"} }, { $group : { _id : 1, app_downloads : {$sum: "$app_downloads"} } } );
I got this result:
failed: exception: $where is not allowed inside of a $match aggregation expression
The question is, can $ where be used in aggregation functions? or is there a way to get the length of a string value in an aggregation function?
Thanks in advance Eric
source share