opendb-mall-goods(副表)和uni-pay-orders(主表)联表查询,获取不到副表内容,单独查询都能获取到内容
主副表如果调换顺序
const res = await db.collection(ordergoods,orders).get()
则只出现opendb-mall-goods的内容,uni-pay-orders表内容为空,见图
查询代码
const orders = db.collection('uni-pay-orders').where(`user_id==$cloudEnv_uid`).field('status,goods_id').getTemp()
const ordergoods = db.collection('opendb-mall-goods').where(`userid==$cloudEnv_uid`).field('_id,totalPrice,skuList').getTemp()
const res = await db.collection(orders,ordergoods).get()
uni-pay-orders(主表)部分必要信息
"permission": {
"read": true,
"create": true,
"update": false,
"delete": false
},
"user_id": {
"title": "用户ID",
"bsonType": "string",
"description": "用户id,参考uni-id-users表",
"foreignKey": "uni-id-users._id",
"forceDefaultValue":{
"$env":"uid"
}
},
"goods_id":{ //关联opendb-mall-goods表
"title": "订单id",
"bsonType": "string",
"description": "订单id,参考opendb-mall-goods表",
"foreignKey": "opendb-mall-goods._id",
"forceDefaultValue":{
"$env":"opendb-mall-goods._id"
}
},
opendb-mall-goods(副表)部分必要信息
"permission": {
"read": true,
"create": true,
"update": true,
"delete": false,
"count": false // 禁止查询数据条数(admin权限用户不受限),
},
"userid": {
"bsonType": "string",
"description": "用户ID, 参考`uni-id-users` 表",
"foreignKey": "uni-id-users._id",
"forceDefaultValue": {
"$env": "uid"
}
},
"name": {
"bsonType": "string",
"description": "一级分类",
"title": "一级分类",
"trim": "both"
},
主副表调换顺序结果