mirror of
https://github.com/nocobase/nocobase
synced 2024-11-16 00:56:33 +00:00
d5d0e1036b
* 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
33 lines
549 B
Markdown
33 lines
549 B
Markdown
---
|
||
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();
|
||
``` |