Feed it @Table model classes written with sequelize-typescript and it builds example JSON shaped like the instance's toJSON() output. That includes the id, createdAt, updatedAt and deletedAt attributes Sequelize adds even when they are not declared in the class.
Unlike the JS page, values here come from each property's TypeScript type rather than the DataType argument. @Column(DataType.DECIMAL) declared as amount: string produces a string.
@Table classes into the Sequelize (TS) box. Add associated models (via @HasMany and the like) to get nested values.Result box for the JSON with the auto-added attributes.@Table options such as timestamps or paranoid to see right away how the date fields change.@Table({ tableName: "invoices", paranoid: true })
export class Invoice extends Model {
@Column(DataType.STRING(20))
number: string;
@Column(DataType.DECIMAL(10, 2))
amount: string;
@Column(DataType.ENUM("draft", "sent", "paid"))
status: "draft" | "sent" | "paid";
@ForeignKey(() => Customer)
@Column
customerId: number;
}{
"id": 0,
"number": "",
"amount": "",
"status": "draft",
"customerId": 0,
"createdAt": "1970-01-01T00:00:00.000Z",
"updatedAt": "1970-01-01T00:00:00.000Z",
"deletedAt": null
}The class has no primary key, so id is added first, and paranoid: true adds deletedAt: null. status takes the first literal of its union, "draft", and amount is an empty string because it is declared as string.
@PrimaryKey, @Column({ primaryKey: true }) or an id property, id: 0 is inserted at the top, both for the root and for associated models.@Table sets timestamps: false, createdAt and updatedAt are appended; renames like createdAt: "created_on", updatedAt: false and paranoid: true (deletedAt: null) are honored per model.Post[] from @HasMany becomes an array; @BelongsTo and @HasOne become nested objects."draft" | "sent" use the first value, and everything inherited through extends Model is ignored.DataType.JSON column typed as an object, e.g. { theme: string }, is filled in that shape.For endpoints that do res.json(await Invoice.findByPk(id)), the output gives a response example whose keys match reality, auto-added attributes included.
Turning on paranoid adds deletedAt to every response. Compare the output with the option on and off to tell API consumers exactly what will change.
id and timestamps from their own @Table options, but foreign keys Sequelize adds implicitly (such as invoiceId on a @HasMany target without a @ForeignKey column) are not invented.allowNull and column renames via @Column({ field: ... }) are ignored, since JSON keys are the property names. @Default("x") and a literal defaultValue in @Column({...}) are used as sample values.underscored: true changes database column names only; toJSON() still uses attribute names, so createdAt in the output is correct.@Column(DataType.INTEGER) count; with no annotation) becomes null.number or string?With MySQL and PostgreSQL, Sequelize returns DECIMAL values as strings by default. Typing it amount: string keeps the type honest, and the example here will show a string too.
declare fields or CreationOptional?Yes. declare id: CreationOptional<number> is read as number, and the same unwrapping applies to NonAttribute<...> and ForeignKey<...>. Helper types beyond these, like InferAttributes, are not expanded.
sequelize.define models written in JavaScript?No. This page reads classes and TypeScript types. Use the Sequelize (JS) to JSON page for define and Model.init models, which reads DataTypes instead.