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: docs/calliope/readme.md
+18-6
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Model
2
2
3
3
The model is at the hearth of this package. It boasts a lot of features, so they have been broken down into the following sections:
4
-
-[Attributes](./attributes.md)
5
-
-[Api calls](./api-calls.md)
6
-
-[Query Building](./query-building.md)
7
-
-[Relationships](./relationships.md)
8
-
-[Timestamps](./timestamps.md)
9
-
-[Additional Methods](#additional-methods)
4
+
-[Attributes](./attributes.md)
5
+
-[Api calls](./api-calls.md)
6
+
-[Query Building](./query-building.md)
7
+
-[Relationships](./relationships.md)
8
+
-[Timestamps](./timestamps.md)
9
+
-[Additional Methods](#additional-methods)
10
10
11
11
## Creating Models
12
12
@@ -18,6 +18,18 @@ import { Model } from '@upfrontjs/framework';
18
18
exportdefaultclassUserextendsModel {}
19
19
```
20
20
21
+
::: tip TIP (Typescript)
22
+
Typescript users may benefit from better typing support if they defined keys and their types on the models
23
+
```ts
24
+
exportdefaultclassUserextendsModel {
25
+
public is_admin?:boolean;
26
+
public age?:number;
27
+
public name?:string;
28
+
}
29
+
```
30
+
This will typehint keys on the model when accessing the above keys like `user.age` and will get type hinted in various methods such as [getAttribute](./attributes.md#getattribute) where both the key, the default value and the return value will be type hinted.
31
+
:::
32
+
21
33
Then you can call your model in various way, for example
0 commit comments