三张表学校、班级、学员做foreignKey关联下怎么用<unicloud-db>从学员里取出学校名称啊
错误的代码
<template>
<unicloud-db collection="test-student,test-class,test-school" field="class_id._id.name,class_id.name,name"
v-slot:default="{data, loading, error, options}">
<view v-for="(item,index) in data" :key="index">
<text>{{item.class_id[0]._id[0].name}}</text><!-- field不能副表再关联,不支持这种写法,应该怎么办呢 -->
<text>{{item.class_id[0].name}}</text>
</view>
</unicloud-db>
</template>
表
{
"_id": {
"description": "存储文档 ID,系统自动生成"
},
"name": {
"bsonType": "string",
"description": "学校名称",
"trim": "both",
"title": "学校名称"
}
},
{
"_id": {
"description": "存储文档 ID,系统自动生成"
},
"school_id": {
"bsonType": "string",
"title": "所属学校",
"description": "所属学校 id,参考`test-school`表",
"foreignKey": "test-school._id"
},
"name": {
"bsonType": "string",
"description": "班级名称",
"trim": "both",
"title": "班级名称"
}
},
{
"_id": {
"description": "存储文档 ID,系统自动生成"
},
"class_id": {
"bsonType": "string",
"title": "所属班级",
"description": "所属班级 id,参考`test-class`表",
"foreignKey": "test-class._id"
},
"name": {
"bsonType": "string",
"description": "学员姓名",
"trim": "both",
"title": "学员姓名"
}
}
5***@qq.com (作者)
有什么替代方案嘛?感谢!
2021-10-27 22:26
DCloud_uniCloud_WYQ
回复 5***@qq.com: 暂无,只能用云函数
2021-10-28 18:15