nocobase/docs/plugins/concepts/models.md
chenos d5d0e1036b
docs: add docs (#75)
* docs: add docs

* ignore dumi theme test

* fix: error TS2717: Subsequent property declarations must have the same type.

* update docs

* deploy gh-pages

* plugins docs

* hash & cname

* exportStatic

* ssr

* vercel

* vercel

* fix: deploy vercel

* Delete vercel.json

* docs

* fix APP_DIST

* on master branch
2021-04-17 21:33:21 +08:00

33 lines
549 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Models - 模型
---
# Models - 模型
将 models 统一放在 `/src/models`、`/lib/models` 目录下,将自动导入 database。
database.table 提供的数据表配置支持指定特殊 model
```ts
import { Model } from '@nocobase/database';
class Test extends Model {
// 在这个类里可以为 Test Model 扩展其他 API
static hello() {
}
}
export default {
name: 'tests',
model: Test,
};
```
调用 Model
```ts
const Test = db.getModel('tests');
// Test 可以调用 hello 方法了
Test.hello();
```