Skip to content

Commit

Permalink
document, please ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
i5ting committed Apr 26, 2023
1 parent 5431a19 commit 01ebe81
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# midway-base

我的想法是根据TypeORM模型定义,快速生成crud

1)配置数据源

```
{
type: 'mysql',
host: '127.0.0.1',
port: 3306,
username: 'root',
password: '',
database: 'demo',
synchronize: true, // 如果第一次使用,不存在表,有同步的需求可以写 true,注意会丢数据
logging: true,
}
```

2)定义模型

比如定义如下

```
{
User:{
name: string,
username: string,
email: string,
phone: string,
website: string,
company: string,
},
Post:{
name: string,
title: string,
body: string,
userId: User.id,
}
}
```

如果想定制,可以扩展属性。

```
{
User:{
name: string,
username: {
type: string,
nullable: true,
default: "i5ting"
},
}
}
```

3)执行命令,生成代码

> $ base abc.json
4)预览

> $ npm run dev

0 comments on commit 01ebe81

Please sign in to comment.