Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | const sequelize = require('../config/database'); const User = require('./User'); const Portfolio = require('./Portfolio'); const Trade = require('./Trade'); const Strategy = require('./Strategy'); const Transaction = require('./Transaction'); const FeeRecord = require('./FeeRecord'); // Define associations User.hasOne(Portfolio, { foreignKey: 'userId', as: 'portfolio' }); Portfolio.belongsTo(User, { foreignKey: 'userId', as: 'user' }); User.hasMany(Trade, { foreignKey: 'userId', as: 'trades' }); Trade.belongsTo(User, { foreignKey: 'userId', as: 'user' }); User.hasMany(Transaction, { foreignKey: 'userId', as: 'transactions' }); Transaction.belongsTo(User, { foreignKey: 'userId', as: 'user' }); Portfolio.hasMany(Trade, { foreignKey: 'portfolioId', as: 'trades' }); Trade.belongsTo(Portfolio, { foreignKey: 'portfolioId', as: 'portfolio' }); Strategy.hasMany(Trade, { foreignKey: 'strategyId', as: 'trades' }); Trade.belongsTo(Strategy, { foreignKey: 'strategyId', as: 'strategy' }); User.hasMany(FeeRecord, { foreignKey: 'userId', as: 'fees' }); FeeRecord.belongsTo(User, { foreignKey: 'userId', as: 'user' }); module.exports = { sequelize, User, Portfolio, Trade, Strategy, Transaction, FeeRecord }; |