糖丶宝可梦
糖丶宝可梦
  • 发布:2022-11-20 16:39
  • 更新:2022-11-21 11:33
  • 阅读:214

unicloud:为什么表中没有的字段也能添加成功?

分类:uniCloud

unicloud:为什么表中没有的字段也能添加成功,而且自动生成的register_date也没有在列表中显示,设置必填字段"required": ["wx_openid"],没有传递也能创建成功,请问是什么情况?是不是我配置少了什么?

login.vue

async wxLogin(wxCode) {  
        try{  
            const {  
                openid  
            } = await getOpenId(wxCode)  
            const record = await db.collection('users').where({openid}).get()  
            if(record.affectedDocs < 1) {  
                const res = await db.collection('users').add({openid,nickName: randomNickName('微信用户', 8)})  
            }  
        }catch(e){  
            //TODO handle the exception  

        }  

    },

index.schema.json

{  
    "bsonType": "object",  
    "required": ["wx_openid"],  
    "permission": {  
        "read": true,  
        "create": true,  
        "update": true,  
        "delete": false  
    },  
    "properties": {  
        "_id": {  
            "description": "ID,系统自动生成",  
            "forceDefaultValue":{  
                "$env": "uid"  
            }  
        },  
        "user_ip": {  
            "description": "用户当前IP地址",  
            "forceDefaultValue": {  
                "$env": "clientIP"  
            }  
        },  
        "nickName": {  
            "bsonType": "string",  
            "label": "昵称",  
            "defaultValue": "",  
            "description": "用户昵称,登录获取的"  
        },  
        "avatarUrl": {  
            "bsonType": "string",  
            "label": "头像",  
            "defaultValue": "",  
            "description": "用户头像图片的 URL,登录获取的"  
        },  
        "wx_openid": {  
            "bsonType": "string",  
            "description": "微信小程序平台openid"  
        },  
        "register_date": {  
            "bsonType": "timestamp",  
            "description": "注册时间",  
            "forceDefaultValue": {  
                "$env": "now"  
            }  
        }  
    }  
}  
2022-11-20 16:39 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

schema只对jql生效

该问题目前已经被锁定, 无法添加新回复