Created
November 20, 2019 15:16
-
-
Save lionants02/36e92c0f4478d838975938fa9c0d673a to your computer and use it in GitHub Desktop.
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
const query = [ | |
{ | |
"$match": { | |
"$and": [ | |
{ | |
"death.date": { | |
"$exists": false | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"$project": { | |
"age": {"$subtract": [{"$year": new Date()}, {"$year": "$birthDateMongo"}]}, | |
"sex": 1 | |
} | |
}, | |
{ | |
"$group": { | |
"_id": {"age": "$age", "sex": "$sex"}, | |
"count": {"$sum": 1} | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment