查询代码 去掉field条件中的goods_id或者_id中任一个,都会报错两个表没有关联,那说明关联没问题
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"
},
卖火柴的咖啡猫 (作者)
通过submit按钮提交的订单数据,提交了订单goods才会有order支付数据,我导出来看看
2023-07-31 11:41
卖火柴的咖啡猫 (作者)
发现order表中"scene": { "bsonType": "string",},"app_version_code": {"bsonType": "int","description": "客户端版本号(数字形式) 如100",导出数据"scene":1001,"app_version_code":"100",把表中类型改成和数据一致,可是并没有任何作用,另外这2个表的内容是没有重复的
2023-07-31 16:24
DCloud_uniCloud_WYQ
回复 1***@qq.com: 看下你帖子里面说的主表和副表关联的字段
2023-08-01 11:05