Skip to content

Commit f3d4cbf

Browse files
Merge pull request #149 from robsontenorio/dev
Release v1.8.0
2 parents 0d803a2 + 1c612b5 commit f3d4cbf

17 files changed

+861
-435
lines changed

.github/workflows/test-and-release.yml

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
- name: Build
8181
run: yarn build
8282

83+
- name: Test
84+
run: yarn test
85+
8386
- name: Upload Coverage to Codecov
8487
uses: codecov/codecov-action@v1
8588
with:

.travis.yml

-8
This file was deleted.

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@
33
</p>
44
<p align="center">
55
<a href="https://codecov.io/gh/robsontenorio/vue-api-query">
6-
<img src="https://codecov.io/gh/robsontenorio/vue-api-query/branch/master/graph/badge.svg" />
7-
</a>
6+
<img src="https://codecov.io/gh/robsontenorio/vue-api-query/branch/master/graph/badge.svg" />
7+
</a>
8+
<a href="https://actions-badge.atrox.dev/robsontenorio/vue-api-query/goto?ref=dev">
9+
<img src="https://img.shields.io/github/workflow/status/robsontenorio/vue-api-query/Test%20and%20Release?style=flat&label=actions&logo=github" />
10+
</a>
811
<a href="https://www.npmjs.com/package/vue-api-query">
912
<img src="https://img.shields.io/npm/dt/vue-api-query.svg" />
10-
</a>
13+
</a>
1114
<a href="https://www.npmjs.com/package/vue-api-query">
1215
<img src="https://img.shields.io/npm/v/vue-api-query.svg" />
13-
</a>
14-
<a href="https://github.com/robsontenorio/vue-api-query/blob/master/LICENSE">
15-
<img src="https://img.shields.io/apm/l/vim-mode.svg" />
16-
</a>
16+
</a>
17+
<a href="https://github.com/robsontenorio/vue-api-query/blob/master/LICENSE">
18+
<img src="https://img.shields.io/apm/l/vim-mode.svg" />
19+
</a>
1720
</p>
1821

1922
# Elegant and simple way to build requests for REST API
@@ -35,6 +38,8 @@ Thanks to the following people who have contributed to this project:
3538
* [@JoaoPedroAS51](https://github.com/JoaoPedroAS51)
3639
* [@Peter-Krebs](https://github.com/Peter-Krebs)
3740

41+
[See all contributors](https://github.com/robsontenorio/vue-api-query/graphs/contributors)
42+
3843
## Thanks
3944

4045
* Inspiration from [milroyfraser/sarala](https://github.com/milroyfraser/sarala).

docs/content/en/api/crud-operations.md

+34
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ category: API
1010

1111
Save or update a model in the database, then return the instance.
1212

13+
<alert type="info">When uploading files, the `Content-Type` will be set to `multipart/form-data`.</alert>
14+
1315
### create
1416

1517
<code-group>
@@ -65,6 +67,38 @@ Save or update a model in the database, then return the instance.
6567
</code-block>
6668
</code-group>
6769

70+
## `patch`
71+
- Returns: `Model | { data: Model }`
72+
73+
Make a `PATCH` request to update a model in the database, then return the instance.
74+
75+
<code-group>
76+
<code-block Label="Query" active>
77+
78+
```js
79+
const model = await Model.find(1)
80+
81+
model.foo = 'bar'
82+
83+
model.patch()
84+
```
85+
86+
</code-block>
87+
<code-block Label="Request">
88+
89+
```http request
90+
PATCH /resource/1
91+
```
92+
93+
</code-block>
94+
</code-group>
95+
96+
Alias for:
97+
```js
98+
model.config({ method: 'PATCH' }).save()
99+
```
100+
101+
<alert type="info">When uploading files, the `Content-Type` will be set to `multipart/form-data`.</alert>
68102

69103
## `delete`
70104

docs/content/en/api/query-builder-methods.md

+66-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,32 @@ Eager load relationships.
1515
await Model.include('user', 'category')
1616
```
1717

18+
#### Array
19+
20+
<alert type="success">Available in version >= v1.8.0</alert>
21+
22+
```js
23+
await Model.include(['user', 'category'])
24+
```
25+
26+
<alert type="info">`with` is an alias of this method.</alert>
27+
1828
## `append`
1929
- Arguments: `(...args)`
2030
- Returns: `self`
2131

2232
Append attributes.
2333

2434
```js
25-
await Model.append('likes')
35+
await Model.append('likes', 'shares')
36+
```
37+
38+
#### Array
39+
40+
<alert type="success">Available in version >= v1.8.0</alert>
41+
42+
```js
43+
await Model.append(['likes', 'shares'])
2644
```
2745

2846
## `select`
@@ -31,12 +49,12 @@ await Model.append('likes')
3149

3250
Set the columns to be selected.
3351

34-
**Single entity:**
52+
#### Single entity
3553
```js
3654
await Model.select(['title', 'content'])
3755
```
3856

39-
**Related entities:**
57+
#### Related entities
4058
```js
4159
await Post.select({
4260
posts: ['title', 'content'],
@@ -54,6 +72,14 @@ Add a basic where clause to the query.
5472
await Model.where('status', 'active')
5573
```
5674

75+
#### Nested
76+
77+
<alert type="success">Available in version >= v1.8.0</alert>
78+
79+
```js
80+
await Model.where(['user', 'status'], 'active')
81+
```
82+
5783
## `whereIn`
5884
- Arguments: `(field, array)`
5985
- Returns: `self`
@@ -64,6 +90,14 @@ Add a "where in" clause to the query.
6490
await Model.whereIn('id', [1, 2, 3])
6591
```
6692

93+
#### Nested
94+
95+
<alert type="success">Available in version >= v1.8.0</alert>
96+
97+
```js
98+
await Model.whereIn(['user', 'id'], [1, 2, 3])
99+
```
100+
67101
## `orderBy`
68102
- Arguments: `(...args)`
69103
- Returns: `self`
@@ -74,6 +108,14 @@ Add an "order by" clause to the query.
74108
await Model.orderBy('-created_at', 'category_id')
75109
```
76110

111+
#### Array
112+
113+
<alert type="success">Available in version >= v1.8.0</alert>
114+
115+
```js
116+
await Model.orderBy(['-created_at', 'category_id'])
117+
```
118+
77119
## `page`
78120
- Arguments: `(value)`
79121
- Returns: `self`
@@ -160,6 +202,22 @@ Build custom endpoints.
160202
</code-block>
161203
</code-group>
162204

205+
## `config`
206+
<alert type="success">Available in version >= v1.8.0</alert>
207+
208+
- Arguments: `(config)`
209+
- Returns: `self`
210+
211+
Configuration of HTTP Instance.
212+
213+
```js
214+
await Model.config({
215+
method: 'PATCH',
216+
header: { /* ... */ },
217+
data: { foo: 'bar' }
218+
}).save()
219+
```
220+
163221
## `get`
164222
- Returns: `Collection | { data: Collection }`
165223

@@ -169,6 +227,8 @@ Execute the query as a "select" statement.
169227
await Model.get()
170228
```
171229

230+
<alert type="info">`all` is an alias of this method.</alert>
231+
172232
## `first`
173233
- Returns: `Model | { data: Model }`
174234

@@ -193,15 +253,15 @@ await Model.find(1)
193253

194254
Execute the query as a "select" statement.
195255

196-
These `$`-prefixed convenience methods always return the requested content as [`JSON`](https://developer.mozilla.org/en-US/docs/Web/API/Body/json).
197-
198256
```js
199257
await Model.$get()
200258
```
201259

202-
<alert type="info">These `$`-prefixed convenience methods always return the requested content.
260+
<alert type="info">These `$`-prefixed convenience methods always return the requested content.
203261
They handle and unwrap responses within "data".</alert>
204262

263+
<alert type="info">`$all` is an alias of this method.</alert>
264+
205265
## `$first`
206266
- Returns: `Model`
207267

0 commit comments

Comments
 (0)