1 | "use strict"
|
2 |
|
3 | module.exports = (config, paths) => {
|
4 |
|
5 | var model;
|
6 |
|
7 | if (config.database) {
|
8 | |
9 |
|
10 |
|
11 | if (config.database.type && config.database.type == "mongodb") {
|
12 | model = new (require('./mongoose.js'))(config.database, paths);
|
13 | }
|
14 | |
15 |
|
16 |
|
17 | else {
|
18 | if (config.database.options) {
|
19 | config.database.config = config.database.options;
|
20 | }
|
21 |
|
22 | if (!config.database.config) {
|
23 | config.database.config = {};
|
24 | config.database.config.dialect = config.database.type;
|
25 | config.database.config.host = config.database.host || 'localhost';
|
26 | }
|
27 | else {
|
28 | if (config.database.config.dialect) {
|
29 | config.database.type = config.database.config.dialect;
|
30 | }
|
31 |
|
32 | if (config.database.config.host) {
|
33 | config.database.host = config.database.config.host;
|
34 | }
|
35 | }
|
36 |
|
37 | model = new (require('./sequelize.js'))(config.database, paths);
|
38 | }
|
39 | }
|
40 |
|
41 | return model;
|
42 | } |
\ | No newline at end of file |