File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -2,8 +2,14 @@ require('./initial');
22const { db } = require ( 'lin-mizar/lin/db' ) ;
33// eslint-disable-next-line no-unused-vars
44const { User, Group, Auth } = require ( 'lin-mizar/lin' ) ;
5+ const { initModels } = require ( './init_models' ) ;
56
7+ /**
8+ * 如果创建失败,请确保你的数据库中没有同名的分组和同名的用户
9+ */
610const run = async ( ) => {
11+ await initModels ( ) ;
12+
713 const group = new Group ( ) ;
814
915 group . name = '普通分组' ;
Original file line number Diff line number Diff line change 1+ const { db } = require ( 'lin-mizar/lin/db' ) ;
2+ // eslint-disable-next-line no-unused-vars
3+ const { User, Group, Auth } = require ( 'lin-mizar/lin' ) ;
4+ const {
5+ UserInterface,
6+ GroupInterface,
7+ AuthInterface
8+ } = require ( 'lin-mizar/lin/interface' ) ;
9+ const lodash = require ( 'lodash' ) ;
10+
11+ const initModels = async ( ) => {
12+ User . init (
13+ Object . assign ( { } , UserInterface . attributes ) ,
14+ lodash . merge (
15+ {
16+ sequelize : db ,
17+ tableName : 'lin_user' ,
18+ modelName : 'user'
19+ } ,
20+ UserInterface . options
21+ )
22+ ) ;
23+
24+ Group . init (
25+ Object . assign ( { } , GroupInterface . attributes ) ,
26+ lodash . merge (
27+ {
28+ sequelize : db ,
29+ tableName : 'lin_group' ,
30+ modelName : 'group'
31+ } ,
32+ GroupInterface . options
33+ )
34+ ) ;
35+
36+ Auth . init (
37+ Object . assign ( { } , AuthInterface . attributes ) ,
38+ lodash . merge (
39+ {
40+ sequelize : db ,
41+ tableName : 'lin_auth' ,
42+ modelName : 'auth'
43+ } ,
44+ AuthInterface . options
45+ )
46+ ) ;
47+ } ;
48+
49+ module . exports = { initModels } ;
You can’t perform that action at this time.
0 commit comments