Socket
Socket
Sign inDemoInstall

@saas-plat/metaschema

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saas-plat/metaschema

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


Version published
Maintainers
1
Created
Source

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',  {
  ...
})

Keywords

FAQs

Package last updated on 06 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc