move associations file
This commit is contained in:
parent
5b35bb603d
commit
107edb70e7
2 changed files with 1 additions and 1 deletions
36
src/database/associations.js
Normal file
36
src/database/associations.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
class AssociationsDefiner {
|
||||
constructor({ models, DataTypes }) {
|
||||
this.models = models;
|
||||
this.DataTypes = DataTypes;
|
||||
}
|
||||
|
||||
define() {
|
||||
this.models.NostrChallengeCreated.hasOne(
|
||||
this.models.NostrChallengeCompleted,
|
||||
{
|
||||
foreignKey: 'challenge',
|
||||
}
|
||||
);
|
||||
this.models.NostrChallengeCompleted.belongsTo(
|
||||
this.models.NostrChallengeCreated,
|
||||
{
|
||||
foreignKey: {
|
||||
name: 'challenge',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
this.models.OfferCreated.hasOne(this.models.OfferDeleted, {
|
||||
foreignKey: 'offer_uuid',
|
||||
});
|
||||
this.models.OfferDeleted.belongsTo(this.models.OfferCreated, {
|
||||
foreignKey: {
|
||||
name: 'offer_uuid',
|
||||
type: this.DataTypes.UUID,
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AssociationsDefiner;
|
||||
Loading…
Add table
Add a link
Reference in a new issue