HJ_Server/src/path_shop_redis2db.ts
xcy fe898ca42c Revert "fix:"
This reverts commit 4fc0da4a70.
2023-12-18 20:06:40 +08:00

31 lines
743 B
TypeScript

import {ctor} from './global';
import {initMongoDB} from './setMongodb';
import {initRedis} from './setRedis';
async function start() {
//连接mongodb
await initMongoDB();
//连接redis
await initRedis();
let shopdata = await G.redis.get("shop")
for (let uid in shopdata) {
for (let shopId in shopdata[uid]) {
await G.mongodb.collection("shop").updateOne(
{uid: uid.slice(1), shopId: shopId.slice(1)},
{$set: shopdata[uid][shopId]}, {upsert: true}
)
console.log(`玩家${uid.slice(1)}商店${shopId.slice(1)}数据写入成功!!`)
}
}
}
//定义全局变量
ctor();
//启动服务
start().then(() => {process.exit()});