Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

没有数据库文件吗 #1

Open
Chanli52580 opened this issue Dec 21, 2021 · 3 comments
Open

没有数据库文件吗 #1

Chanli52580 opened this issue Dec 21, 2021 · 3 comments

Comments

@Chanli52580
Copy link

没有数据库文件吗

@hangjob
Copy link
Owner

hangjob commented Dec 22, 2021

启动egg.js服务,程序会自动创建数据库,自动同步,你只需要配置好数据库服务,在egg/app/router.js

 // 模型添加字段同步数据库
app.beforeStart(async () => {
  await app.model.sync({alter: true});//force  false 为不覆盖 true会删除再创建; alter true可以 添加或删除字段;
 });

@alexnest
Copy link

表结构初始化完了但表数据为空,能不能也给个脚本初始化table data,menu和mock data对应起来的呢?谢谢大佬

@hangjob
Copy link
Owner

hangjob commented Jan 17, 2022

@alexnest 好的,我已经添加了用户表的测试数据,

cd /egg 目录下

先启动服务 npm run dev

然后生成假数据 npm run fake

具体操作文档

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants