From f8e723d39e50f610e1ac57a6c81433ab4f821790 Mon Sep 17 00:00:00 2001 From: handongxun Date: Sun, 22 Nov 2020 10:48:40 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20schema=20enum=20=E6=8B=86=E5=88=863?= =?UTF-8?q?=E4=B8=AA=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/uniCloud/schema.md | 62 ++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/docs/uniCloud/schema.md b/docs/uniCloud/schema.md index 733949657..755f80f3e 100644 --- a/docs/uniCloud/schema.md +++ b/docs/uniCloud/schema.md @@ -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"字段必填。 -- GitLab