|
2 | 2 | * Keep this file in sync with the code in the "Usage" section in typescript.md |
3 | 3 | */ |
4 | 4 | import { |
5 | | - Sequelize, |
6 | | - Model, |
7 | | - ModelDefined, |
8 | | - DataTypes, |
9 | | - HasManyGetAssociationsMixin, |
10 | | - HasManyAddAssociationMixin, |
11 | | - HasManyHasAssociationMixin, |
12 | | - Association, |
13 | | - HasManyCountAssociationsMixin, |
14 | | - HasManyCreateAssociationMixin, |
15 | | - Optional, |
| 5 | + Association, DataTypes, HasManyAddAssociationMixin, HasManyCountAssociationsMixin, |
| 6 | + HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, HasManyHasAssociationMixin, Model, |
| 7 | + ModelDefined, Optional, Sequelize |
16 | 8 | } from "sequelize"; |
17 | 9 |
|
18 | 10 | const sequelize = new Sequelize("mysql://root:asd123@localhost:3306/mydb"); |
@@ -59,6 +51,7 @@ interface ProjectAttributes { |
59 | 51 | id: number; |
60 | 52 | ownerId: number; |
61 | 53 | name: string; |
| 54 | + description?: string; |
62 | 55 | } |
63 | 56 |
|
64 | 57 | interface ProjectCreationAttributes extends Optional<ProjectAttributes, "id"> {} |
@@ -114,6 +107,10 @@ Project.init( |
114 | 107 | type: new DataTypes.STRING(128), |
115 | 108 | allowNull: false, |
116 | 109 | }, |
| 110 | + description: { |
| 111 | + type: new DataTypes.STRING(128), |
| 112 | + allowNull: true, |
| 113 | + }, |
117 | 114 | }, |
118 | 115 | { |
119 | 116 | sequelize, |
@@ -204,6 +201,7 @@ async function doStuffWithUser() { |
204 | 201 |
|
205 | 202 | const project = await newUser.createProject({ |
206 | 203 | name: "first!", |
| 204 | + ownerId: 123, |
207 | 205 | }); |
208 | 206 |
|
209 | 207 | const ourUser = await User.findByPk(1, { |
|
0 commit comments