Answer the question
In order to leave comments, you need to log in
How to make a proper Sequelize request?
@Table({
tableName: 'jobs',
timestamps: true
})
export class Job extends Model {
@Column({
type: DataType.UUID,
defaultValue: UUIDV4,
primaryKey: true,
unique: true,
allowNull: false
})
id: string;
@Index('instrument_id')
@Column({
type: DataType.STRING,
allowNull: false
})
instrument_id: string;
@HasMany(() => Candle)
candles: Candle[]
}
@Table({
tableName: 'candles',
timestamps: true
})
export class Candle extends Model {
@Column({
type: DataType.UUID,
defaultValue: UUIDV4,
primaryKey: true,
unique: true,
allowNull: false
})
id: string;
@BelongsTo(() => Job)
job: Job
@ForeignKey(() => Job)
job_id: string
}
Job.id | Job.instrument_id | Кол-во строк с job_id=Job.id в таблице Candle
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question