Last active
May 21, 2020 10:32
-
-
Save seozed/8d59e4850e63f8eb69a7af81c113f05a to your computer and use it in GitHub Desktop.
mongo 统计字段的长度并汇总
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.getCollection("mastersportal_counrse").aggregate([ | |
{ | |
"$project": { | |
"overview": { | |
"$strLenCP": "$overview" | |
}, | |
"about": { | |
"$strLenCP": "$about" | |
} | |
} | |
}, | |
{ | |
$group: { | |
_id: null, | |
totalAmount: { | |
$sum: { | |
$add: ["$overview", "$about"] | |
} | |
} | |
} | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment