描述现有的数据含义。可以一目了然的阅读每个表、每个字段的用途。
设定数据操作权限(permission)。什么样的角色可以读/写哪些数据,都在这里配置。
设定字段值域能接受的格式(validator),比如不能为空、需符合指定的正则格式。
设定字段之间的约束关系(fieldRules),比如字段结束时间需要晚于字段开始时间。
设置数据的默认值(defaultValue/forceDefaultValue),比如服务器当前时间、当前用户id等。
设定多个表的字段间映射关系(foreignKey),将多个表按一个虚拟表直接查询,大幅简化联表查询。
根据schema自动生成前端界面(schema2code),包括列表、详情、新建和编辑页面,自动处理校验规则。
"bsonType"
:
"object"
,
"description"
:
"单词表"
,
"required"
: [],
"permission"
: {
"read"
:
true
,
"create"
:
true
,
"update"
:
true
,
"delete"
:
true
"properties"
: {
"_id"
: {
"description"
:
"ID,系统自动生成"
"user_id"
: {
"bsonType"
:
"string"
,
"description"
:
"创建者"
,
"forceDefaultValue"
: {
"
$env
"
:
"uid"
"foreignKey"
:
"uni-id-users._id"
"en_title"
: {
"bsonType"
:
"string"
,
"description"
:
"英文单词"
,
"maxLength"
: 20,
"title"
:
"英文单词"
,
"required"
:
true
,
"trim"
:
"both"
"ch_title"
: {
"bsonType"
:
"string"
,
"description"
:
"中文单词"
,
"maxLength"
: 20,
"title"
:
"中文单词"
,
"required"
:
true
,
"trim"
:
"both"
"description"
: {
"bsonType"
:
"string"
,
"description"
:
"描述"
,
"maxLength"
: 500,
"title"
:
"描述"
,
"required"
:
true
,
"trim"
:
"both"
"example"
: {
"bsonType"
:
"string"
,
"description"
:
"例句"
,
"maxLength"
: 20,
"title"
:
"例句"
,
"required"
:
true
,
"trim"
:
"both"
其中。permission 允许前端操作数据库,properties 字段中的 reuired 代表是否必填
3,生成页面
上传shhema文件
使用shema 文件生成基本页面
4,适当的修改
修改page.json文件的tabBar 为
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#007AFF",
"borderStyle": "black",
"backgroundColor": "#FFFFFF",
"list": [{
"pagePath": "pages/word/list",
"iconPath": "static/tabbar/grid.png",
"selectedIconPath": "static/tabbar/grid_active.png",
"text": "我的单词表"
"pagePath": "pages/ucenter/ucenter",
"iconPath": "static/tabbar/me.png",
"selectedIconPath": "static/tabbar/me_active.png",
"text": "我的"
达到隐藏下其他页面的目的
修改个人中心的内容为
