relationship

This commit is contained in:
counterweight 2025-03-10 13:05:33 +01:00
parent afc8a6d04d
commit 3b2edb4ca9
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
3 changed files with 17 additions and 0 deletions

View file

@ -5,6 +5,21 @@ class AssociationsDefiner {
} }
define() { 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, { this.models.OfferCreated.hasOne(this.models.OfferDeleted, {
foreignKey: 'offer_uuid', foreignKey: 'offer_uuid',
}); });

View file

@ -17,6 +17,7 @@ class NostrChallengeCompletedProvider {
challenge: { challenge: {
type: this.DataTypes.STRING, type: this.DataTypes.STRING,
allowNull: false, allowNull: false,
unique: true,
}, },
signed_event: { signed_event: {
type: this.DataTypes.JSONB, type: this.DataTypes.JSONB,

View file

@ -17,6 +17,7 @@ class NostrChallengeCreatedProvider {
challenge: { challenge: {
type: this.DataTypes.STRING, type: this.DataTypes.STRING,
allowNull: false, allowNull: false,
unique: true,
}, },
expires_at: { expires_at: {
type: this.DataTypes.DATE, type: this.DataTypes.DATE,