@@ -145,15 +145,38 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
145
145
this . log ( '\n# Server\n' ) ;
146
146
147
147
this . prompt ( [ {
148
- type : 'confirm' ,
149
- name : 'mongoose' ,
150
- message : 'Would you like to use mongoDB with Mongoose for data modeling?'
148
+ type : 'checkbox' ,
149
+ name : 'odms' ,
150
+ message : 'What would you like to use for data modeling?' ,
151
+ choices : [
152
+ {
153
+ value : 'mongoose' ,
154
+ name : 'Mongoose (MongoDB)' ,
155
+ checked : true
156
+ } ,
157
+ {
158
+ value : 'sequelize' ,
159
+ name : 'Sequelize (MySQL, SQLite, MariaDB, PostgreSQL)' ,
160
+ checked : false
161
+ }
162
+ ]
163
+ } , {
164
+ type : 'list' ,
165
+ name : 'models' ,
166
+ message : 'What would you like to use for the default models?' ,
167
+ choices : [ 'Mongoose' , 'Sequelize' ] ,
168
+ filter : function ( val ) {
169
+ return val . toLowerCase ( ) ;
170
+ } ,
171
+ when : function ( answers ) {
172
+ return answers . odms && answers . odms . length > 1 ;
173
+ }
151
174
} , {
152
175
type : 'confirm' ,
153
176
name : 'auth' ,
154
177
message : 'Would you scaffold out an authentication boilerplate?' ,
155
178
when : function ( answers ) {
156
- return answers . mongoose ;
179
+ return answers . odms && answers . odms . length !== 0 ;
157
180
}
158
181
} , {
159
182
type : 'checkbox' ,
@@ -183,15 +206,29 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
183
206
type : 'confirm' ,
184
207
name : 'socketio' ,
185
208
message : 'Would you like to use socket.io?' ,
186
- // to-do: should not be dependent on mongoose
209
+ // to-do: should not be dependent on ODMs
187
210
when : function ( answers ) {
188
- return answers . mongoose ;
211
+ return answers . odms && answers . odms . length !== 0 ;
189
212
} ,
190
213
default : true
191
214
} ] , function ( answers ) {
192
215
if ( answers . socketio ) this . filters . socketio = true ;
193
- if ( answers . mongoose ) this . filters . mongoose = true ;
194
216
if ( answers . auth ) this . filters . auth = true ;
217
+ if ( answers . odms . length > 0 ) {
218
+ var models ;
219
+ if ( ! answers . models ) {
220
+ models = answers . odms [ 0 ] ;
221
+ } else {
222
+ models = answers . models ;
223
+ }
224
+ this . filters . models = true ;
225
+ this . filters [ models + 'Models' ] = true ;
226
+ answers . odms . forEach ( function ( odm ) {
227
+ this . filters [ odm ] = true ;
228
+ } . bind ( this ) ) ;
229
+ } else {
230
+ this . filters . noModels = true ;
231
+ }
195
232
if ( answers . oauth ) {
196
233
if ( answers . oauth . length ) this . filters . oauth = true ;
197
234
answers . oauth . forEach ( function ( oauthStrategy ) {
@@ -265,6 +302,10 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
265
302
this . config . set ( 'registerSocketsFile' , 'server/config/socketio.js' ) ;
266
303
this . config . set ( 'socketsNeedle' , '// Insert sockets below' ) ;
267
304
305
+ this . config . set ( 'insertModels' , true ) ;
306
+ this . config . set ( 'registerModelsFile' , 'server/sqldb/index.js' ) ;
307
+ this . config . set ( 'modelsNeedle' , '// Insert models below' ) ;
308
+
268
309
this . config . set ( 'filters' , this . filters ) ;
269
310
this . config . forceSave ( ) ;
270
311
} ,
0 commit comments