index.js
964 Bytes
/**
* Created by Tommy Huang on 18/03/21.
*/
const User = require('./user')
const BorrowList = require('./borrowList')
const Period = require('./periods')
const WechatTicket = require('./wechatTickets')
const Friendship = require('./friendships')
const Report = require('./reports')
const RepaymentRecord = require('./repaymentRecord')
BorrowList.belongsTo(User, {foreignKey: 'creditor_id', as: 'Creditor'})
BorrowList.belongsTo(User, {foreignKey: 'borrower_id', as: 'Borrower'})
User.belongsToMany(User, { through: Friendship, as: 'friend', foreignKey: 'user_id', otherKey: 'friend_id'})
BorrowList.hasMany(Report)
Report.belongsTo(BorrowList)
BorrowList.hasMany(Period)
Period.belongsTo(BorrowList)
BorrowList.hasMany(RepaymentRecord)
RepaymentRecord.belongsTo(BorrowList)
module.exports = {
User: User,
BorrowList: BorrowList,
WechatTicket: WechatTicket,
Friendship: Friendship,
Report: Report,
Period: Period,
Repayment: RepaymentRecord
}