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()});


