import cloud from '@lafjs/cloud' const { MongoClient } = require('mongodb'); const db1 = cloud.database(); /**查询备份数据库 */ export default async function (ctx: FunctionContext) { // const uri = process.env.BACKUP_MONGODB_URI; // const dbName = 'sealaf-cno56wxmj7'; // let res = await db1.collection("users").where({ totalLevel: { $gt: 10000 } }).update({ totalLevel:0},{multi:true}); // return res; // let data = []; // for(let i=0;i item.name === collectionName); // if (!exists) { // console.log(`collection "${collectionName}" not found`); // return; // } // for (let i = 0; i < 3; i++) { // console.log(data[i]); // const user = await db.collection(collectionName).findOne({ _id: data[i] }); // let data1 = { // endLevelNum: user.endLevelNum || 0, // totalLevel: user.totalLevel || user.levelAmount, // userLevel: user.userLevel || 0, // forcedUpdate: true, // } // if (user) { // //data1.coinAmount += 10000; // //console.log(data1); // let res22 = await db1.collection("users").where({ _id: data[i] }).update(data1); // //console.log(res22) // } // } // } catch (err) { // console.error('MongoDB error:', err); // } finally { // console.log("断开连接") // await client.close(); // } // let res = await db1.collection("users").where({ endLevelNum:99999999999999 }).get(); // let data=[]; // for(let i=0;i20000){ // data.push(res.data[i]._id); // } // } // console.log(JSON.stringify(data)); }