'use strict'; exports.main = async (event, context) => { //event为客户端上传的参数 console.log('event : ', event) const db = uniCloud.database(); const collection = db.collection('mustgo-user'); let res = await collection.orderBy("total_running_distance", "desc").get() console.log(res) let userlist = new Array; for (let i = 0; i < res.data.length; i++) { let user = { "rank": i + 1, "icon": res.data[i]["icon"], "username": res.data[i]["name"], "distance":res.data[i]["total_running_distance"] } userlist.push(user) } //返回数据给客户端 return { "code": 200, "message": "成功返回跑步累计排名", "data": { "userList": userlist } } };