File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,42 @@ export default class User extends Model {
8383}
8484```
8585
86+ ### Typescript
87+
88+ If we are working on a Typescript project, we can infer the types of the fields, so we have intellisense.
89+
90+ #### Directly in Model
91+ ``` ts{}[~/models/User.ts]
92+ import Model from './Model'
93+
94+ export default class User extends Model {
95+ firstName: string
96+ lastName: string
97+ age: number
98+
99+ ...
100+ }
101+ ```
102+
103+ #### Using an Interface
104+ ``` ts{}[~/models/User.ts]
105+ import Model from './Model'
106+
107+ interface User {
108+ firstName: string
109+ lastName: string
110+ age: number
111+ }
112+
113+ class User extends Model {
114+ ...
115+ }
116+
117+ export default User
118+ ```
119+
120+ <alert type =" info " >You can use ` ! ` operator to make non-null assertion.</alert >
121+
86122## Changing the Primary Key
87123
88124<alert type =" info " >By default, the ` primaryKey ` is set to ` id ` .</alert >
You can’t perform that action at this time.
0 commit comments