提交 f8e723d3 编写于 作者: d-u-a's avatar d-u-a

docs: schema enum 拆分3个示例

上级 f68b9b65
......@@ -95,7 +95,8 @@
### enum属性@enum
支持本地数据/云端数据
简单本地数据
```json
{
......@@ -105,23 +106,30 @@
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
// role 云端数据, enum属性的值和clientdb组件的写法一致,clientdb组件 https://uniapp.dcloud.net.cn/uniCloud/uni-clientdb-component
// 通过clientdb提交数据时多一次查库请求以校验数据是否有效
"role": {
"bsonType": "array",
"description": "角色",
"description": "角色,不允许重复",
"label": "角色",
"enum": {
"collection": "uni-id-roles", // 表名,这里使用 uni-id-roles表举例,在uniCloud控制台使用 opendb 创建此表
"field": "role_name as text, role_id as value", //字段筛选,需要 as 成前端组件支持的字段名 text,value
"where": "", // 查询条件
"orderby": "" // 排序字段及正序倒叙设置
}
"enum": [1, 2, 3]
}
}
}
```
复杂本地数据
```json
{
"bsonType": "object",
"required": [],
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
// role2 本地数据
"role2": {
"role": {
"bsonType": "array",
"description": "角色,不允许重复2",
"description": "角色,不允许重复",
"label": "角色",
"enum": [
{
......@@ -139,6 +147,34 @@
```
云端数据
```json
{
"bsonType": "object",
"required": [],
"properties": {
"_id": {
"description": "存储文档 ID(用户 ID),系统自动生成"
},
// role 云端数据, enum属性的值和clientdb组件的写法一致,clientdb组件 https://uniapp.dcloud.net.cn/uniCloud/uni-clientdb-component
// 通过clientdb提交数据时多一次查库请求以校验数据是否有效
"role": {
"bsonType": "array",
"description": "角色",
"label": "角色",
"enum": {
"collection": "uni-id-roles", // 表名,这里使用 uni-id-roles表举例,在uniCloud控制台使用 opendb 创建此表
"field": "role_name as text, role_id as value", //字段筛选,需要 as 成前端组件支持的字段名 text,value
"where": "", // 查询条件
"orderby": "" // 排序字段及正序倒叙设置
}
}
}
}
```
### 基本示例
假使一个表有5个字段:"name", "year", "major", "address", "gpa"。其中前4个字段是必填字段,然后"address"字段类型为json object,它下面又有若干子字段,其中"city"字段必填。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册