猫史档案馆


pro数据库报错

用户:七叶寂照秘密主promax七叶寂照秘密主promax查看:0 回复:1 评论:0 创建时间:2024-01-29T16:52:54


const sql = storage.getDataStorage('users_v0_0')

async function getdata(entity){
    var id = entity.player.userId
    while(1){
        try{
            let data = await sql.get(id)
            console.log('数据读取成功'+JSON.stringify(data.value))
            var v = data.value
            if (data && data.value && v.ver == world.ver){
                console.log('数据读取成功'+JSON.stringify(data.value))
                return data
            }else if(v.ver != world.ver){
                console.log('数据版本过期')
                sql.set(id,{'coin':entity.coin,'exp':entity.exp,'ver':VER,'item':entity.item,'other':entity.other})
                console.log('更新成功:'+JSON.stringify(data.value))
                return data
            }else{
                console.log('正在创建数据')
                sql.set(id,{'coin':entity.coin,'exp':entity.exp,'ver':world.VER,'item':entity.item,'other':entity.other})
                console.log('创建成功:'+JSON.stringify(data.value))
                return data
            }
        }
        catch(e){
            console.log(e)
        }
    }
}

上面是一个数据库获取信息代码

初次运行时报错

TypeError: Cannot read properties of undefined (reading 'value')   at getdata 


回复

上一页1 页 / 共 1下一页
飞熊jSrt飞熊jSrt

沙发捏

点赞0


评论