cb/server/laf-cloud/functions/clearPHBDataById.ts
2026-07-02 11:22:24 +08:00

24 lines
785 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import cloud from '@lafjs/cloud'
const db=cloud.database();
import Utils from "@/Utils";
export default async function (ctx: FunctionContext) {
let db1 = "691093093cf0c4532ba4fd9c";
const uid=ctx.body.uid;
const gameName = ctx.body.gameName;
if (gameName == "iaa") {
db1 = "691097ac3cf0c4532ba4fd9e";
}
let rankInfo = await db.collection("sRank").where({ _id: db1 }).getOne();
let total = JSON.parse(rankInfo.data.total);
for(var key in total){
for(let i=0;i<total[key].length;i++){
if(total[key][i].id==uid){
total[key].splice(i,1);
//console.log(key+" 删除一个 "+uid);
}
}
}
let ret1 = await db.collection("sRank").where({ _id: db1 }).update({ total: JSON.stringify(total) });
return { data: '删除完毕' }
}