Skip to content

Commit 90c748c

Browse files
committed
added explanation on why id is omiited
also added an explanation on why the orchestraId field must be defined in the interface, although we don't explicitly define it
1 parent cd6720c commit 90c748c

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

express-main-example/src/sequelize/models/instrument.model.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ interface InstrumentAttributes {
55
id: number;
66
type: string;
77
purchaseDate: Date;
8+
9+
// We need to specify the 'orchestraId' field here,
10+
// because it will automatically be defined later on
11+
// when Sequelize applies the associations
812
orchestraId: number;
913
}
1014

15+
// we can omit the 'id' field, since we aren't required
16+
// to set it manually when creating a new entry
1117
interface InstrumentCreationAttributes
1218
extends Omit<InstrumentAttributes, "id"> {}
1319

express-main-example/src/sequelize/models/orchestra.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ interface OrchestraAttributes {
66
name: string;
77
}
88

9+
// we can omit the 'id' field, since we aren't required
10+
// to set it manually when creating a new entry
911
interface OrchestraCreationAttributes extends Omit<OrchestraAttributes, "id"> {}
1012

1113
export const Orchestra: ModelDefined<

express-main-example/src/sequelize/models/user.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ interface UserAttributes {
66
username: string;
77
}
88

9+
// we can omit the 'id' field, since we aren't required
10+
// to set it manually when creating a new entry
911
interface UserCreationAttributes extends Omit<UserAttributes, "id"> {}
1012

1113
export const User: ModelDefined<

0 commit comments

Comments
 (0)