You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
660 B

mongo = require("./mongoHelp.js")
agg = [
{
'$sort': {
'ts': -1
}
}, {
'$unwind': {
'path': '$votes',
'includeArrayIndex': 'string',
'preserveNullAndEmptyArrays': false
}
}, {
'$sort': {
'votes.u': 1
}
}, {
'$group': {
'_id': {
'User': '$votes.u'
},
'claims': {
'$sum': '$votes.claimable'
}
}
}, {
'$sort': {
'claims': -1
}
}, {
'$limit': 10
}
]
mongo.aggregate('avalon5', 'contents', agg).then(res => {
res.forEach(element => {
element.claims=Math.floor(element.claims/100)
console.log(element)
})
})