diff options
| author | Adam Soltys <[email protected]> | 2020-03-11 15:10:40 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-03-11 15:10:40 -0700 |
| commit | c0888fab024cc9f7c99812bfabf9d7774312dbf7 (patch) | |
| tree | cad95683af97432f6092a2c2bae10fbb7a588db5 /db/index.js | |
| parent | bf2b51f0c2ae9b8f0f330dde6411e45fc0da8a25 (diff) | |
| download | coinos-server-c0888fab024cc9f7c99812bfabf9d7774312dbf7.tar.gz coinos-server-c0888fab024cc9f7c99812bfabf9d7774312dbf7.zip | |
refactor
Diffstat (limited to 'db/index.js')
| -rw-r--r-- | db/index.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/db/index.js b/db/index.js new file mode 100644 index 00000000..dac6924e --- /dev/null +++ b/db/index.js @@ -0,0 +1,22 @@ +const Sequelize = require("sequelize"); +const conf = config.dbOptions; + +db = new Sequelize(conf.database, conf.username, conf.password, { + host: conf.host, + dialect: conf.dialect, + logging: false, + dialectOptions: { multipleStatements: true } +}); + +require("./models/users.js"); +require("./models/payments.js"); + +db["User"].hasMany(db["Payment"], { + as: "payments", + foreignKey: "user_id" +}); + +db["Payment"].belongsTo(db["User"], { + as: "user", + foreignKey: "user_id" +}); |
