Skip to content

Commit

Permalink
Merge pull request #149 from robsontenorio/dev
Browse files Browse the repository at this point in the history
Release v1.8.0
  • Loading branch information
JoaoPedroAS51 authored Nov 10, 2020
2 parents 0d803a2 + 1c612b5 commit f3d4cbf
Show file tree
Hide file tree
Showing 17 changed files with 861 additions and 435 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ jobs:
- name: Build
run: yarn build

- name: Test
run: yarn test

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
</p>
<p align="center">
<a href="https://codecov.io/gh/robsontenorio/vue-api-query">
<img src="https://codecov.io/gh/robsontenorio/vue-api-query/branch/master/graph/badge.svg" />
</a>
<img src="https://codecov.io/gh/robsontenorio/vue-api-query/branch/master/graph/badge.svg" />
</a>
<a href="https://actions-badge.atrox.dev/robsontenorio/vue-api-query/goto?ref=dev">
<img src="https://img.shields.io/github/workflow/status/robsontenorio/vue-api-query/Test%20and%20Release?style=flat&label=actions&logo=github" />
</a>
<a href="https://www.npmjs.com/package/vue-api-query">
<img src="https://img.shields.io/npm/dt/vue-api-query.svg" />
</a>
</a>
<a href="https://www.npmjs.com/package/vue-api-query">
<img src="https://img.shields.io/npm/v/vue-api-query.svg" />
</a>
<a href="https://github.com/robsontenorio/vue-api-query/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg" />
</a>
</a>
<a href="https://github.com/robsontenorio/vue-api-query/blob/master/LICENSE">
<img src="https://img.shields.io/apm/l/vim-mode.svg" />
</a>
</p>

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

[See all contributors](https://github.com/robsontenorio/vue-api-query/graphs/contributors)

## Thanks

* Inspiration from [milroyfraser/sarala](https://github.com/milroyfraser/sarala).
Expand Down
34 changes: 34 additions & 0 deletions docs/content/en/api/crud-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ category: API

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

<alert type="info">When uploading files, the `Content-Type` will be set to `multipart/form-data`.</alert>

### create

<code-group>
Expand Down Expand Up @@ -65,6 +67,38 @@ Save or update a model in the database, then return the instance.
</code-block>
</code-group>

## `patch`
- Returns: `Model | { data: Model }`

Make a `PATCH` request to update a model in the database, then return the instance.

<code-group>
<code-block Label="Query" active>

```js
const model = await Model.find(1)

model.foo = 'bar'

model.patch()
```

</code-block>
<code-block Label="Request">

```http request
PATCH /resource/1
```

</code-block>
</code-group>

Alias for:
```js
model.config({ method: 'PATCH' }).save()
```

<alert type="info">When uploading files, the `Content-Type` will be set to `multipart/form-data`.</alert>

## `delete`

Expand Down
72 changes: 66 additions & 6 deletions docs/content/en/api/query-builder-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,32 @@ Eager load relationships.
await Model.include('user', 'category')
```

#### Array

<alert type="success">Available in version >= v1.8.0</alert>

```js
await Model.include(['user', 'category'])
```

<alert type="info">`with` is an alias of this method.</alert>

## `append`
- Arguments: `(...args)`
- Returns: `self`

Append attributes.

```js
await Model.append('likes')
await Model.append('likes', 'shares')
```

#### Array

<alert type="success">Available in version >= v1.8.0</alert>

```js
await Model.append(['likes', 'shares'])
```

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

Set the columns to be selected.

**Single entity:**
#### Single entity
```js
await Model.select(['title', 'content'])
```

**Related entities:**
#### Related entities
```js
await Post.select({
posts: ['title', 'content'],
Expand All @@ -54,6 +72,14 @@ Add a basic where clause to the query.
await Model.where('status', 'active')
```

#### Nested

<alert type="success">Available in version >= v1.8.0</alert>

```js
await Model.where(['user', 'status'], 'active')
```

## `whereIn`
- Arguments: `(field, array)`
- Returns: `self`
Expand All @@ -64,6 +90,14 @@ Add a "where in" clause to the query.
await Model.whereIn('id', [1, 2, 3])
```

#### Nested

<alert type="success">Available in version >= v1.8.0</alert>

```js
await Model.whereIn(['user', 'id'], [1, 2, 3])
```

## `orderBy`
- Arguments: `(...args)`
- Returns: `self`
Expand All @@ -74,6 +108,14 @@ Add an "order by" clause to the query.
await Model.orderBy('-created_at', 'category_id')
```

#### Array

<alert type="success">Available in version >= v1.8.0</alert>

```js
await Model.orderBy(['-created_at', 'category_id'])
```

## `page`
- Arguments: `(value)`
- Returns: `self`
Expand Down Expand Up @@ -160,6 +202,22 @@ Build custom endpoints.
</code-block>
</code-group>

## `config`
<alert type="success">Available in version >= v1.8.0</alert>

- Arguments: `(config)`
- Returns: `self`

Configuration of HTTP Instance.

```js
await Model.config({
method: 'PATCH',
header: { /* ... */ },
data: { foo: 'bar' }
}).save()
```

## `get`
- Returns: `Collection | { data: Collection }`

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

<alert type="info">`all` is an alias of this method.</alert>

## `first`
- Returns: `Model | { data: Model }`

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

Execute the query as a "select" statement.

These `$`-prefixed convenience methods always return the requested content as [`JSON`](https://developer.mozilla.org/en-US/docs/Web/API/Body/json).

```js
await Model.$get()
```

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

<alert type="info">`$all` is an alias of this method.</alert>

## `$first`
- Returns: `Model`

Expand Down
Loading

0 comments on commit f3d4cbf

Please sign in to comment.