inital commit

This commit is contained in:
2024-12-12 15:55:37 +03:00
commit 13c18e116a
17 changed files with 858 additions and 0 deletions

40
aggregate.js Normal file
View File

@@ -0,0 +1,40 @@
db = connect( 'mongodb://root:example@127.0.0.1:27017/strava?authSource=admin' );
let result = db.workout.aggregate([{
$match: {
type: 'Run'
}
}, {
$set: {
date: {
$dateFromString: {
dateString: '$start_date'
}
}
}
}, {
$group: {
_id: {
$dateToString: {
format: '%Y-%m',
date: '$date'
}
},
totalMonthDistance: {
$sum: {
$divide: [
'$distance',
1000
]
}
}
}
}, {
$match: {
totalMonthDistance: {
$gte: 150
}
}
}]);
console.log(result);