From c6dc858ee5491e6c584d94d702438e9b24adbfc7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 30 Aug 2021 14:48:26 -0700 Subject: handle conversions for internal payments --- db/index.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'db') 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"); -- cgit v1.2.3