diff options
| author | Adam Soltys <[email protected]> | 2021-08-30 14:48:26 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-08-30 16:03:09 -0700 |
| commit | c6dc858ee5491e6c584d94d702438e9b24adbfc7 (patch) | |
| tree | 412344ab540dc81f209a965eaf82e5621a85b4d3 /db | |
| parent | 7d3cc287e862e590c7cc85a8ce99eb2782ff84af (diff) | |
| download | coinos-server-c6dc858ee5491e6c584d94d702438e9b24adbfc7.tar.gz coinos-server-c6dc858ee5491e6c584d94d702438e9b24adbfc7.zip | |
handle conversions for internal payments
Diffstat (limited to 'db')
| -rw-r--r-- | db/index.js | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/db/index.js b/db/index.js index a3d29743..532b5e77 100644 --- a/db/index.js +++ b/db/index.js @@ -13,11 +13,11 @@ db = new Sequelize( host: dbOptions.connection.host, dialect: "mariadb", logging: false, - dialectOptions: { multipleStatements: true, timezone: "Etc/GMT+7" } + dialectOptions: { multipleStatements: true, timezone: "Etc/GMT+7" }, } ); -db.authenticate().catch(err => { +db.authenticate().catch((err) => { console.debug("Error connecting to database: " + err.message); console.log(dbOptions.connection.database + "." + dbOptions.connection.user); }); @@ -69,100 +69,100 @@ const { User, Account, Payment, Invoice, Key, Order, Referral } = db; // move relationships to specfic models User.hasMany(Account, { as: "accounts", - foreignKey: "user_id" + foreignKey: "user_id", }); User.hasMany(Invoice, { as: "invoices", - foreignKey: "user_id" + foreignKey: "user_id", }); User.hasMany(Key, { as: "keys", - foreignKey: "user_id" + foreignKey: "user_id", }); User.hasMany(Order, { as: "orders", - foreignKey: "user_id" + foreignKey: "user_id", }); User.hasMany(Payment, { as: "payments", - foreignKey: "user_id" + foreignKey: "user_id", }); User.belongsTo(Account, { as: "account", - foreignKey: "account_id" + foreignKey: "account_id", }); Invoice.belongsTo(Account, { as: "account", - foreignKey: "account_id" + foreignKey: "account_id", }); Account.belongsTo(User, { as: "user", - foreignKey: "user_id" + foreignKey: "user_id", }); Invoice.belongsTo(User, { as: "user", - foreignKey: "user_id" + foreignKey: "user_id", }); Key.belongsTo(User, { as: "user", - foreignKey: "user_id" + foreignKey: "user_id", }); Payment.belongsTo(Account, { as: "account", - foreignKey: "account_id" + foreignKey: "account_id", }); Payment.belongsTo(User, { as: "user", - foreignKey: "user_id" + foreignKey: "user_id", }); Payment.belongsTo(Invoice, { as: "invoice", - foreignKey: "invoice_id" + foreignKey: "invoice_id", }); Order.belongsTo(User, { as: "user", - foreignKey: "user_id" + foreignKey: "user_id", }); Order.belongsTo(Account, { as: "acc1", - foreignKey: "a1_id" + foreignKey: "a1_id", }); Order.belongsTo(Account, { as: "acc2", - foreignKey: "a2_id" + foreignKey: "a2_id", }); User.hasMany(Referral, { as: "referral_codes", - foreignKey: "sponsor_id" + foreignKey: "sponsor_id", }); User.hasMany(Referral, { as: "sponsors", - foreignKey: "user_id" + foreignKey: "user_id", }); Referral.belongsTo(User, { as: "sponsor", - foreignKey: "sponsor_id" + foreignKey: "sponsor_id", }); Referral.belongsTo(User, { as: "user", - foreignKey: "user_id" + foreignKey: "user_id", }); debug("added model relationships"); |
