You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -61,8 +61,8 @@ class Person extends Model<Person> {
61
61
hobbies:Hobby[];
62
62
}
63
63
```
64
-
The model needs to extend the `Model` class and has to be annotated with the `@Table` decorator. All properties, that
65
-
should appear as a column in the database, require the `@Column` annotation.
64
+
The model needs to extend the `Model` class and has to be annotated with the `@Table` decorator. All properties that
65
+
should appear as a column in the database require the `@Column` annotation.
66
66
67
67
### `@Table`
68
68
The `@Table` annotation can be used without passing any parameters. To specify some more define options, use
@@ -111,7 +111,7 @@ Decorator | Description
111
111
`@DeletedAt` | sets `timestamps=true`, `paranoid=true` and `deletedAt='deletionDate'`
112
112
113
113
### `@Column`
114
-
The `@Column` annotation can be used without passing any parameters. But therefore it is necessary, that
114
+
The `@Column` annotation can be used without passing any parameters. But therefore it is necessary that
115
115
the js type can be inferred automatically (see [Type inference](#type-inference) for details).
116
116
```typescript
117
117
@Column
@@ -201,8 +201,8 @@ const sequelize = new Sequelize({
201
201
modelPaths: [__dirname+'/models']
202
202
});
203
203
```
204
-
Before you can use your models, you have to tell sequelize where they can be found. So either set `modelPaths` in the
205
-
sequlize config or add the required models later on by calling `sequelize.addModels([Person])` or
204
+
Before you can use your models you have to tell sequelize where they can be found. So either set `modelPaths` in the
205
+
sequelize config or add the required models later on by calling `sequelize.addModels([Person])` or
206
206
`sequelize.addModels([__dirname + '/models'])`:
207
207
208
208
```typescript
@@ -233,7 +233,7 @@ person.save();
233
233
```
234
234
235
235
### Find and update
236
-
Finding and updating entries do also work like using native sequelize. So see sequelize
236
+
Finding and updating entries does also work like using native sequelize. So see sequelize
237
237
[docs](http://docs.sequelizejs.com/manual/tutorial/models-usage.html) for more details.
238
238
```typescript
239
239
Person
@@ -340,7 +340,7 @@ Decorator | Description
340
340
`@BelongsTo(relatedModelGetter: () => typeof Model, options: AssociationOptionsBelongsTo)` | sets `SourceModel.belongsTo(RelatedModel, ...)` while `as` is key of annotated property and `options` are additional association options
341
341
`@HasMany(relatedModelGetter: () => typeof Model)` | sets `SourceModel.hasMany(RelatedModel, ...)` while `as` is key of annotated property and `foreignKey` is resolved from target related class
342
342
`@HasMany(relatedModelGetter: () => typeof Model, foreignKey: string)` | sets `SourceModel.hasMany(RelatedModel, ...)` while `as` is key of annotated property and `foreignKey` is explicitly specified value
343
-
`@HasMany(relatedModelGetter: () => typeof Model, options: AssociationOptionsHasMany)` | sets `SourceModel.hasMany(RelatedModel, ...)` while `as` is key of annotated property and `options` are additional association otions
343
+
`@HasMany(relatedModelGetter: () => typeof Model, options: AssociationOptionsHasMany)` | sets `SourceModel.hasMany(RelatedModel, ...)` while `as` is key of annotated property and `options` are additional association options
344
344
`@HasOne(relatedModelGetter: () => typeof Model)` | sets `SourceModel.hasOne(RelatedModel, ...)` while `as` is key of annotated property and `foreignKey` is resolved from target related class
345
345
`@HasOne(relatedModelGetter: () => typeof Model, foreignKey: string)` | sets `SourceModel.hasOne(RelatedModel, ...)` while `as` is key of annotated property and `foreignKey` is explicitly specified value
346
346
`@HasOne(relatedModelGetter: () => typeof Model, options: AssociationOptionsHasOne)` | sets `SourceModel.hasOne(RelatedModel, ...)` while `as` is key of annotated property and `options` are additional association options
@@ -350,7 +350,7 @@ Decorator | Description
350
350
`@BelongsToMany(relatedModelGetter: () => typeof Model, through: string, foreignKey: string, otherKey: string)` | sets `SourceModel.belongsToMany(RelatedModel, {through: throughString, ...})` while `as` is key of annotated property and `foreignKey`/`otherKey` are explicitly specified values
351
351
`@BelongsToMany(relatedModelGetter: () => typeof Model, through: string, options: AssociationOptionsBelongsToMany)` | sets `SourceModel.belongsToMany(RelatedModel, {through: throughString, ...})` while `as` is key of annotated property and `options` are additional association values, including `foreignKey` and `otherKey`.
352
352
353
-
Note that when using AssociationOptions, certain properties will be overwritten when the association is built based on reflection metadata or explicit attribute parameters. For example, `as` will always be the annotated property's name, and `through` will be the explicitly stated value.
353
+
Note that when using AssociationOptions, certain properties will be overwritten when the association is built, based on reflection metadata or explicit attribute parameters. For example, `as` will always be the annotated property's name, and `through` will be the explicitly stated value.
354
354
355
355
### Multiple relations of same models
356
356
*sequelize-typescript* resolves the foreign keys by identifying the corresponding class references.
@@ -407,7 +407,7 @@ explicitly:
407
407
With the creation of a relation, sequelize generates some method on the corresponding
408
408
models. So when you create a 1:n relation between `ModelA` and `ModelB`, an instance of `ModelA` will
409
409
have the functions `getModelBs`, `setModelBs`, `addModelB`, `removeModelB`, `hasModelB`. These functions still exist with *sequelize-typescript*.
410
-
But TypeScript will not know of them and in turn will complain, when you try to access `getModelB`, `setModelB` or
410
+
But TypeScript wont recognize them and will complain if you try to access `getModelB`, `setModelB` or
411
411
`addModelB`. To make TypeScript happy, the `Model.prototype` of *sequelize-typescript* has `$set`, `$get`, `$add`
412
412
functions.
413
413
```typescript
@@ -425,7 +425,7 @@ class ModelB extends Model<ModelB> {
425
425
a:ModelA;
426
426
}
427
427
```
428
-
To use them pass the property key of the respective relation as the first parameter:
428
+
To use them, pass the property key of the respective relation as the first parameter:
0 commit comments