diff options
| author | Ranabir Guin <[email protected]> | 2021-05-14 23:37:49 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2021-06-09 16:05:31 -0700 |
| commit | 3a185023419983eb18c9b2408939fc0d17c2dc0a (patch) | |
| tree | d6828f4db205ab424aa9561aa17814f531b6bf83 /db | |
| parent | 87550a2ae7ad61803279cb6fcfddfd5392524d26 (diff) | |
| download | coinos-server-3a185023419983eb18c9b2408939fc0d17c2dc0a.tar.gz coinos-server-3a185023419983eb18c9b2408939fc0d17c2dc0a.zip | |
add FK for orders -> users in index; access user_accounts
Diffstat (limited to 'db')
| -rw-r--r-- | db/index.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/db/index.js b/db/index.js index 658a51a0..de9116a8 100644 --- a/db/index.js +++ b/db/index.js @@ -52,10 +52,10 @@ require("./normalized/waiting_list.js"); const { User, Account, Payment, Invoice, Key, Order } = db; // move relationships to specfic models -// User.hasMany(Account, { -// as: "accounts", -// foreignKey: "user_id" -// }); +User.hasMany(Account, { + as: "accounts", + foreignKey: "user_id" +}); User.hasMany(Invoice, { as: "invoices", @@ -67,6 +67,11 @@ User.hasMany(Key, { foreignKey: "user_id" }); +User.hasMany(Order, { + as: "orders", + foreignKey: "user_id" +}); + User.hasMany(Payment, { as: "payments", foreignKey: "user_id" @@ -82,10 +87,10 @@ Invoice.belongsTo(Account, { foreignKey: "account_id" }); -// Account.belongsTo(User, { -// as: "user", -// foreignKey: "user_id" -// }); +Account.belongsTo(User, { + as: "user", + foreignKey: "user_id" +}); Invoice.belongsTo(User, { as: "user", |
