1.0.21 • Published 3 years ago

@saas-plat/metaschema v1.0.21

Weekly downloads
-
License
MPL-2.0
Repository
github
Last release
3 years ago

metaschema

一种用javascript语言来定义元数据的模式

标准的模型

业务实体:

  • Entity
  • BaseData
  • CompositeData
  • CategoryTree
  • CategoryData
  • LevelData

查询对象:

  • Table
  • DataTable
  • SumTable
  • TreeTable
  • UnionTable

视图模型:

  • ViewModel
  • FormModel
  • FormListModel
  • TreeListModel
  • CardModel

UI模板: View

业务规则:
Rule

基于标准模型定义一个业务对象

import {
  BaseData,
} from '@saas-plat/metaschema';

export default BaseData('BankAccount',  {
  Code: {
    mapping: 'code',
    validator: (rule, value)=>{
      return !!value;
    }
  },
  Name: String,
  NewBalance: Number,
  // ------------ actions -----------------
  customAction1: async (data) => {
    ...
  }
})

自定义行为定义

this指向模型实例

action(...args){
  ...
}

自定义校验定义

接收5个参数,分别是规则定义,待验证值,数据源,选项,上下文,this指向模型实例 返回false校验失败

validator(rule, value, source, options, context){
  return true
}

schemas是可以扩展的

需要定义schema{name, types, syskeys, fields}

const NewModel1 = () => require('./schemas/NewModel1');

封装Model的定义函数

NewModel1 = (name, fields) => {
  return new Model(name, Schema.create(NewModel1(), fields));
}

开发者定义新模型

import {
  NewModel1,
} from 'otherschema';

export default NewModel1('xxxx',  {
  ...
})
1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.12

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago