0
나는 hasMany 및 belongsTo 메소드에 서로 연결된 ReceiptItems, Payments에서 연관된 행을 검색하려고합니다.Sequelize.Js-PostgreSQL 관련 테이블의 행을 소속 테이블에서 가져 오는 방법은 무엇입니까?
다음내 테이블 관계 :
// One to Many Relationship between receiptitems and receipts
db.Receipts.hasMany(db.ReceiptItems,{ foreignKey : 'receipt_id'});
db.ReceiptItems.belongsTo(db.Receipts,{ foreignKey : 'receipt_id'});
// One to Many Relationship between ReceiptItems and Payments
// This relation exists due to solve the problem of paying the debts later on !
db.Receipts.hasMany(db.Payments, { foreignKey : 'receipt_id' });
db.Payments.belongsTo(db.Receipts, { foreignKey : 'receipt_id' });
// One to many Relationship between Receipts and Plates
db.Plates.hasMany(db.Receipts, { foreignKey : 'plate_id' });
db.Receipts.belongsTo(db.Plates, { foreignKey : 'plate_id' });
plate_id에 속하는 영수증을 찾아 내 방법은, 그것은 영수증을 발견하지만, 그와 연관된 ReceiptItems 및 결제를 검색하지 않습니다 영수증 (null이 아님, 성공적인 컴백으로 인해 관련된 테이블과 관련된 필드를 볼 수 없습니다.)