# @saas-plat/metadomain

> 使用领域元数据提供通过配置的方式快速定义业务模型

Latest version **1.0.42** (published 2021-01-06) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install @saas-plat/metadomain
pnpm add @saas-plat/metadomain
yarn add @saas-plat/metadomain
bun add @saas-plat/metadomain
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.42 |
| Published | 2021-01-06 |
| First published | 2020-04-09 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 90.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | saas-plat.com |
| Maintainers | caizx666 |
| Keywords | metadomain |

## Links

- npm: https://www.npmjs.com/package/@saas-plat/metadomain
- Repository: https://github.com/saas-plat/metadomain
- Homepage: https://github.com/saas-plat/metadomain#readme
- Issues: https://github.com/saas-plat/metadomain/issues
- npm.io page: https://npm.io/package/@saas-plat/metadomain

## Dependencies (10)

- [debug](https://npm.io/package/debug.md) ^3.1.0
- [lodash](https://npm.io/package/lodash.md) ^4.17.19
- [moment](https://npm.io/package/moment.md) ^2.27.0
- [mongodb](https://npm.io/package/mongodb.md) ^3.5.9
- [shortid](https://npm.io/package/shortid.md) ^2.2.15
- [sourced](https://npm.io/package/sourced.md) ^0.1.4
- [eventasync](https://npm.io/package/eventasync.md) ^1.0.0
- [node-cache](https://npm.io/package/node-cache.md) ^4.2.1
- [en-inflectors](https://npm.io/package/en-inflectors.md) ^1.0.12
- [sourced-repo-mongo-hotfix](https://npm.io/package/sourced-repo-mongo-hotfix.md) >=0.0.1

## Recent versions

- 1.0.42 (latest) — 2021-01-06
- 1.0.41 — 2020-07-20
- 1.0.40 — 2020-07-18
- 1.0.37 — 2020-07-06
- 1.0.36 — 2020-05-06
- 1.0.35 — 2020-05-05
- 1.0.34 — 2020-04-17
- 1.0.33 — 2020-04-17
- 1.0.32 — 2020-04-17
- 1.0.29 — 2020-04-09
- 1.0.28 — 2020-04-09

## README

# 领域模型
使用领域元数据提供通过配置的方式快速定义业务模型

## 实体的定义
```js
const {
  MetaEntity
} = require('@saas-plat/metadomain');

const BankAccount = MetaEntity.createModel('BankAccount', {
  fields:{
    "Code": {type:"string",mapping:'code'},
    "Name": {type:"string",mapping:'name'},
    "NewBalance": "number"
  }
});

```

## 实体类型与服务

- 基础实体
- 层级实体
- 分类实体
- 复合实体


## 事件的迁移
给每个实体的event进行迁移， 每个实体可以写一个升级脚本
通常对一个组织下的所有实体开始升级，升级时需要锁定数据提交

```js
const migration = new Migration([Department1Rep, WarehouseRep], [Department2Rep, WarehouseRep]);
await db.lock(ns);
migration.onAction(objs => {
  // 执行升级规则
   ...
})
await migration.up('v1','v2');
await db.unlock(ns);
```

---
_Source: https://npm.io/package/@saas-plat/metadomain · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
