File tree Expand file tree Collapse file tree 1 file changed +48
-4
lines changed Expand file tree Collapse file tree 1 file changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -12,9 +12,9 @@ npm install @stantanasi/jsonapi-client
1212
1313## Usage
1414
15- Create JSON: API model
15+ ### Create JSON: API model
1616
17- ### JavaScript
17+ #### JavaScript
1818
1919``` javascript
2020import { model , Schema } from ' @stantanasi/jsonapi-client' ;
@@ -38,7 +38,7 @@ Article.register('articles')
3838export default Article
3939```
4040
41- ### TypeScript
41+ #### TypeScript
4242
4343``` typescript
4444import { model , Schema } from ' @stantanasi/jsonapi-client' ;
@@ -71,7 +71,7 @@ Article.register('articles')
7171export default Article
7272```
7373
74- Use methods
74+ ### Use methods
7575
7676``` typescript
7777import { connect } from ' @stantanasi/jsonapi-client'
@@ -109,6 +109,50 @@ await article.save()
109109await article .delete ()
110110```
111111
112+ #### Inclusion of Related Resources
113+
114+ ``` typescript
115+ // GET /articles?include=author.comments HTTP/1.1
116+ await Article .find ()
117+ .include ({ author: { comments: true } })
118+ ```
119+
120+ #### Sparse Fieldsets
121+
122+ ``` typescript
123+ // GET /articles?fields[articles]=title,author HTTP/1.1
124+ await Article .find ()
125+ .fields ({
126+ articles: [' title' , ' author' ],
127+ })
128+ ```
129+
130+ #### Sorting
131+
132+ ``` typescript
133+ // GET /articles?sort=-createdAt HTTP/1.1
134+ await Article .find ()
135+ .sort ({ createdAt: ' desc' })
136+ ```
137+
138+ #### Pagination
139+
140+ ``` typescript
141+ // GET /articles?page[limit]=10&page[offset]=0 HTTP/1.1
142+ await Article .find ()
143+ .limit (10 )
144+ .offset (0 )
145+ ```
146+
147+ #### Filtering
148+
149+ ``` typescript
150+ // GET /articles?filter[title]=JSON:API%20paints%20my%20bikeshed! HTTP/1.1
151+ await Article .find ({
152+ title: ' JSON:API paints my bikeshed!' ,
153+ })
154+ ```
155+
112156Please refer to the [ example] ( ./example/README.md ) folder to see how to use it
113157
114158## Contributing
You can’t perform that action at this time.
0 commit comments