Skip to content

Commit 1381b6d

Browse files
committed
docs: cleanup readme and older versions usage
1 parent 731161e commit 1381b6d

File tree

2 files changed

+96
-106
lines changed

2 files changed

+96
-106
lines changed

CHANGELOG.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,67 @@ Initial release with Changelog.
1313
### Features
1414

1515
- infer bigint data type ([#893](https://github.com/RobinBuschmann/sequelize-typescript/issues/893)) ([7c467d4](https://github.com/RobinBuschmann/sequelize-typescript/commit/7c467d404a200b3153cc7aa2605d1e542bef3da9))
16+
17+
## Older versions
18+
19+
### ⚠️ sequelize@5
20+
21+
`sequelize@5` requires `sequelize-typescript@1`. See
22+
[documentation](https://github.com/RobinBuschmann/sequelize-typescript/tree/1.0.0) for version `1.0`.
23+
24+
```sh
25+
npm install [email protected]
26+
```
27+
28+
#### V5 Model definition
29+
30+
```typescript
31+
import { Table, Model } from 'sequelize-typescript'
32+
33+
@Table
34+
class Person extends Model<Person> {}
35+
```
36+
37+
### ⚠️ sequelize@4
38+
39+
`sequelize@4` requires `[email protected]`. See
40+
[documentation](https://github.com/RobinBuschmann/sequelize-typescript/tree/0.6.X) for version `0.6`.
41+
42+
```sh
43+
npm install [email protected]
44+
```
45+
46+
### Upgrade to `sequelize-typescript@2`
47+
48+
- `sequelize-typescript@2` only works with `[email protected]>=`.
49+
For `sequelize@5` use `[email protected]`.
50+
51+
#### Breaking Changes
52+
53+
- All breaking changes of `sequelize@6` are also valid for `sequelize-typescript@2`.
54+
See [Upgrade to v6](https://sequelize.org/master/manual/upgrade-to-v6.html) for details.
55+
- `@types/bluebird` is no longer needed, `sequelize@6` removed usage of `bluebird`
56+
- Sequelize v6.2 introduced additional model attributes typings, which affects how the model is defined.
57+
- See below comparison between V5 and V6 model definition to show how to upgrade models.
58+
- For more details, see [sequelize typescript docs](https://sequelize.org/master/manual/typescript.html).
59+
60+
### Upgrade to `sequelize-typescript@1`
61+
62+
`sequelize-typescript@1` only works with `sequelize@5>=`.
63+
For `sequelize@4` & `sequelize@3` use `[email protected]`.
64+
65+
#### Breaking Changes @5
66+
67+
All breaking changes of `sequelize@5` are also valid for `sequelize-typescript@1`.
68+
See [Upgrade to v5](https://sequelize.org/v5/manual/upgrade-to-v5.html) for details.
69+
70+
#### Official Sequelize Typings
71+
72+
sequelize-typescript now uses the official typings bundled with sequelize
73+
(See [this](https://sequelize.org/v5/manual/upgrade-to-v5.html#typescript-support)).
74+
Please note the following details:
75+
76+
- Most of the sequelize-typescript interfaces of the previous version are replaced by the official ones
77+
- `@types/sequelize` is no longer used
78+
- `@types/bluebird` is no longer an explicit dependency
79+
- The official typings are less strict than the former sequelize-typescript ones

README.md

Lines changed: 32 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
Decorators and some other features for sequelize (v6).
99

1010
- [Installation](#installation)
11-
- [Upgrade to `sequelize-typescript@2`](#upgrade-to-sequelize-typescript2)
12-
- [Upgrade to `sequelize-typescript@1`](#upgrade-to-sequelize-typescript1)
1311
- [Model Definition](#model-definition)
1412
- [`@Table` API](#table-api)
1513
- [`@Column` API](#column-api)
@@ -27,7 +25,7 @@ Decorators and some other features for sequelize (v6).
2725
- [Indexes](#indexes)
2826
- [`@Index` API](#index)
2927
- [`createIndexDecorator()` API](#createindexdecorator)
30-
- [Repository mode](#repository-mode-1)
28+
- [Repository mode](#repository-mode)
3129
- [How to enable repository mode?](#how-to-enable-repository-mode)
3230
- [How to use repository mode?](#how-to-use-repository-mode)
3331
- [How to use associations with repository mode?](#how-to-use-associations-with-repository-mode)
@@ -45,13 +43,8 @@ Decorators and some other features for sequelize (v6).
4543
- additional typings as documented [here](https://sequelize.org/master/manual/typescript.html) and [reflect-metadata](https://www.npmjs.com/package/reflect-metadata)
4644

4745
```sh
48-
npm install sequelize
49-
npm install @types/node @types/validator
50-
npm install reflect-metadata
51-
```
52-
53-
```sh
54-
npm install sequelize-typescript
46+
npm install --save-dev @types/node @types/validator
47+
npm install sequelize reflect-metadata sequelize-typescript
5548
```
5649

5750
Your `tsconfig.json` needs the following flags:
@@ -62,48 +55,46 @@ Your `tsconfig.json` needs the following flags:
6255
"emitDecoratorMetadata": true
6356
```
6457

65-
### ⚠️ sequelize@5
58+
### Sequelize Options
6659

67-
`sequelize@5` requires `sequelize-typescript@1`. See
68-
[documentation](https://github.com/RobinBuschmann/sequelize-typescript/tree/1.0.0) for version `1.0`.
69-
70-
```sh
71-
npm install [email protected]
72-
```
60+
- `SequelizeConfig` renamed to `SequelizeOptions`
61+
- `modelPaths` property renamed to `models`
7362

74-
### ⚠️ sequelize@4
63+
### Scopes Options
7564

76-
`sequelize@4` requires `[email protected]`. See
77-
[documentation](https://github.com/RobinBuschmann/sequelize-typescript/tree/0.6.X) for version `0.6`.
65+
The `@Scopes` and `@DefaultScope` decorators now take lambda's as options
7866

79-
```sh
80-
npm install [email protected]
67+
```ts
68+
@DefaultScope(() => ({...}))
69+
@Scopes(() => ({...}))
8170
```
8271

83-
## Upgrade to `sequelize-typescript@2`
84-
85-
- `sequelize-typescript@2` only works with `[email protected]>=`.
86-
For `sequelize@5` use `[email protected]`.
87-
88-
### Breaking Changes
72+
instead of deprecated way:
8973

90-
- All breaking changes of `sequelize@6` are also valid for `sequelize-typescript@2`.
91-
See [Upgrade to v6](https://sequelize.org/master/manual/upgrade-to-v6.html) for details.
92-
- `@types/bluebird` is no longer needed, `sequelize@6` removed usage of `bluebird`
93-
- Sequelize v6.2 introduced additional model attributes typings, which affects how the model is defined.
94-
- See below comparison between V5 and V6 model definition to show how to upgrade models.
95-
- For more details, see [sequelize typescript docs](https://sequelize.org/master/manual/typescript.html).
74+
```ts
75+
@DefaultScope({...})
76+
@Scopes({...}))
77+
```
9678

97-
#### V5 Model definition
79+
## Model definition
9880

9981
```typescript
100-
import { Table, Model } from 'sequelize-typescript'
82+
import { Table, Column, Model, HasMany } from 'sequelize-typescript'
10183

10284
@Table
103-
class Person extends Model<Person> {}
85+
class Person extends Model {
86+
@Column
87+
name: string
88+
89+
@Column
90+
birthday: Date
91+
92+
@HasMany(() => Hobby)
93+
hobbies: Hobby[]
94+
}
10495
```
10596

106-
#### V6 Model definition (less strict)
97+
### Less strict
10798

10899
```typescript
109100
import { Table, Model } from 'sequelize-typescript'
@@ -112,10 +103,7 @@ import { Table, Model } from 'sequelize-typescript'
112103
class Person extends Model {}
113104
```
114105

115-
#### V6 Model definition (more strict)
116-
117-
- ⚠️ not yet implemented in `sequelize-typescript`
118-
- to allow more strict model attributes type-checks, you can define `ModelAttributes` and `ModelCreationAttributes` interfaces
106+
### More strict
119107

120108
```typescript
121109
import { Optional } from 'sequelize'
@@ -132,70 +120,6 @@ interface PersonCreationAttributes extends Optional<PersonAttributes, 'id'> {}
132120
class Person extends Model<PersonAttributes, PersonCreationAttributes> {}
133121
```
134122

135-
## Upgrade to `sequelize-typescript@1`
136-
137-
`sequelize-typescript@1` only works with `sequelize@5>=`.
138-
For `sequelize@4` & `sequelize@3` use `[email protected]`.
139-
140-
### Breaking Changes @5
141-
142-
All breaking changes of `sequelize@5` are also valid for `sequelize-typescript@1`.
143-
See [Upgrade to v5](https://sequelize.org/v5/manual/upgrade-to-v5.html) for details.
144-
145-
#### Official Sequelize Typings
146-
147-
sequelize-typescript now uses the official typings bundled with sequelize
148-
(See [this](https://sequelize.org/v5/manual/upgrade-to-v5.html#typescript-support)).
149-
Please note the following details:
150-
151-
- Most of the sequelize-typescript interfaces of the previous version are replaced by the official ones
152-
- `@types/sequelize` is no longer used
153-
- `@types/bluebird` is no longer an explicit dependency
154-
- The official typings are less strict than the former sequelize-typescript ones
155-
156-
#### Sequelize Options
157-
158-
- `SequelizeConfig` renamed to `SequelizeOptions`
159-
- `modelPaths` property renamed to `models`
160-
161-
#### Scopes Options
162-
163-
The `@Scopes` and `@DefaultScope` decorators now take lambda's as options
164-
165-
```ts
166-
@DefaultScope(() => ({...}))
167-
@Scopes(() => ({...}))
168-
```
169-
170-
instead of deprecated way:
171-
172-
```ts
173-
@DefaultScope({...})
174-
@Scopes({...}))
175-
```
176-
177-
### Repository Mode
178-
179-
With `sequelize-typescript@1` comes a repository mode. See [docs](#repository-mode-1) for details.
180-
181-
## Model definition
182-
183-
```typescript
184-
import { Table, Column, Model, HasMany } from 'sequelize-typescript'
185-
186-
@Table
187-
class Person extends Model {
188-
@Column
189-
name: string
190-
191-
@Column
192-
birthday: Date
193-
194-
@HasMany(() => Hobby)
195-
hobbies: Hobby[]
196-
}
197-
```
198-
199123
The model needs to extend the `Model` class and has to be annotated with the `@Table` decorator. All properties that
200124
should appear as a column in the database require the `@Column` annotation.
201125

@@ -791,6 +715,8 @@ class Person extends Model {
791715

792716
## Repository mode
793717

718+
With `sequelize-typescript@1` comes a repository mode. See [docs](#repository-mode-1) for details.
719+
794720
The repository mode makes it possible to separate static operations like `find`, `create`, ... from model definitions.
795721
It also empowers models so that they can be used with multiple sequelize instances.
796722

0 commit comments

Comments
 (0)