Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs #130

Merged
merged 53 commits into from
Oct 31, 2020
Merged

docs #130

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ef12a76
docs: add nuxt docs
JoaoPedroAS51 Oct 19, 2020
e3037f5
docs: add introduction, installation, configuration, usage and nuxt e…
JoaoPedroAS51 Oct 19, 2020
3a3b373
docs: add api docs
JoaoPedroAS51 Oct 19, 2020
859e1b3
docs: update configuration and usage
JoaoPedroAS51 Oct 19, 2020
c0698c4
Merge branch 'dev' into add-docs
JoaoPedroAS51 Oct 19, 2020
37e4fe1
ci(docs): update deploy action
JoaoPedroAS51 Oct 19, 2020
0b035f8
Merge branch 'dev' into docs
JoaoPedroAS51 Oct 19, 2020
c303ced
ci: fix docs working directory
JoaoPedroAS51 Oct 19, 2020
b2812f5
docs: fix url
JoaoPedroAS51 Oct 19, 2020
3437f6e
docs: fix base url
JoaoPedroAS51 Oct 19, 2020
835be2d
Merge branch 'dev' into docs
JoaoPedroAS51 Oct 19, 2020
258ea83
docs: fix pages position
JoaoPedroAS51 Oct 19, 2020
f3b81e6
Merge remote-tracking branch 'upstream/dev' into docs
JoaoPedroAS51 Oct 22, 2020
8802383
docs: update configuration and api options
JoaoPedroAS51 Oct 22, 2020
dbdcb6e
docs: update api docs
JoaoPedroAS51 Oct 22, 2020
c81454b
docs(model options): update docs
JoaoPedroAS51 Oct 22, 2020
0801c68
docs(query builder methods): update docs
JoaoPedroAS51 Oct 22, 2020
04bd9a8
docs(model options): add `primaryKey` default value
JoaoPedroAS51 Oct 22, 2020
7dad02a
docs(model options): fix typo
JoaoPedroAS51 Oct 22, 2020
7c5b6e7
docs(example): rename file of nuxt example
JoaoPedroAS51 Oct 22, 2020
56253d4
docs: remove usage section
JoaoPedroAS51 Oct 22, 2020
a6b87ed
docs: add building query section
JoaoPedroAS51 Oct 22, 2020
87237af
docs: fix typo
JoaoPedroAS51 Oct 26, 2020
db69ffb
docs: add "including relationships"
JoaoPedroAS51 Oct 26, 2020
e0fafa7
docs: add helpers
JoaoPedroAS51 Oct 26, 2020
a1b4e6d
docs(operations): fix typo
JoaoPedroAS51 Oct 26, 2020
e40ffdd
docs(api): update query builder methods
JoaoPedroAS51 Oct 26, 2020
98aa8f5
docs: fix response of section "including relationships"
JoaoPedroAS51 Oct 26, 2020
94d8542
docs: add "appending attributes"
JoaoPedroAS51 Oct 26, 2020
6e04b5d
docs: add "selecting fields" and update other docs
JoaoPedroAS51 Oct 26, 2020
0f92b16
docs: add "paginating" and add missing colons.
JoaoPedroAS51 Oct 26, 2020
d02a7f5
docs: add api reference to "selecting fields" section
JoaoPedroAS51 Oct 26, 2020
4f45706
docs: update "paginating" section
JoaoPedroAS51 Oct 26, 2020
d6934a4
docs: add "applying parameters"
JoaoPedroAS51 Oct 26, 2020
ce31cf9
docs: add "calling a custom resource"
JoaoPedroAS51 Oct 26, 2020
9a086c7
docs: add api reference of `params` and `custom`
JoaoPedroAS51 Oct 26, 2020
240da67
docs: add "composing without request"
JoaoPedroAS51 Oct 26, 2020
8d03374
docs: remove unnecessary responses
JoaoPedroAS51 Oct 26, 2020
c2c0551
docs: update "calling a custom resource"
JoaoPedroAS51 Oct 26, 2020
8205ae0
docs: fix crud order
JoaoPedroAS51 Oct 26, 2020
7021faa
docs: fix create request
JoaoPedroAS51 Oct 26, 2020
8d66628
docs: update example of delete operation
JoaoPedroAS51 Oct 26, 2020
31a0c89
docs: add "mixing everything up"
JoaoPedroAS51 Oct 26, 2020
d49aa90
docs: fix append example
JoaoPedroAS51 Oct 26, 2020
1ecd6da
docs: add "performing operations"
JoaoPedroAS51 Oct 27, 2020
e318449
docs: update `select` and `custom`
JoaoPedroAS51 Oct 27, 2020
d7b943d
docs: update model options
JoaoPedroAS51 Oct 27, 2020
bc4e8c0
docs: update configuration
JoaoPedroAS51 Oct 27, 2020
aead69c
docs: add vue example
JoaoPedroAS51 Oct 27, 2020
0e2c734
Merge branch 'dev' into docs
JoaoPedroAS51 Oct 27, 2020
62b6eae
docs: update "needless parent request"
JoaoPedroAS51 Oct 27, 2020
975f4da
docs: remove helpers
JoaoPedroAS51 Oct 27, 2020
ed902d1
Merge branch 'dev' into docs
JoaoPedroAS51 Oct 31, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.nuxt
dist
97 changes: 97 additions & 0 deletions docs/content/en/api/crud-operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
title: CRUD Operations
description: 'CRUD Operations.'
position: 8
category: API
---

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

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

### create

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

```js
const model = new Model({ foo: 'bar' })

model.save()
```

</code-block>
<code-block Label="Query 2">

```js
const model = new Model()

model.foo = 'bar'

model.save()
```

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

```http request
POST /resource
```

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

### update

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

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

model.foo = 'bar'

model.save()
```

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

```http request
PUT /resource/1
```

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


## `delete`

Delete the model from the database.

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

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

model.delete()
```

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

```http request
GET /resource/1
```

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

```http request
DELETE /resource/1
```

</code-block>
</code-group>
160 changes: 160 additions & 0 deletions docs/content/en/api/model-options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
title: Model Options
description: 'Model Options.'
position: 6
category: API
---

## Global Options

It's recommended to define the global options in your [Base Model](/configuration#creating-a-base-model),
in order to abstract configuration from your models.

### `$http`
- Returns: `HTTP Client Instance`

Instance of the HTTP client which is used to make requests.

See [Installation](/installation)

### `baseURL`
- Returns: `string`

Base URL which is used and prepended to make requests.

See [Configuration](/configuration#creating-a-base-model)

```js
baseURL() {
return 'http://my-api.com'
}
```

### `request`
- Arguments: `(config)`
- Returns: `HTTP Client Request`

Request method which is used to make requests.

See [Configuration](/configuration#creating-a-base-model)

```js
request(config) {
return this.$http.request(config)
}
```

### `parameterNames`
- Returns: `object`

This method can be overridden in the model to customize the name of the query parameters.

See [Configuration](/configuration#customizing-query-parameters)

```js
parameterNames() {
return {
include: 'include',
filter: 'filter',
sort: 'sort',
fields: 'fields',
append: 'append',
page: 'page',
limit: 'limit'
}
}
```

#### `include`
- Default: `include`
- Returns: `string`

#### `filter`
- Default: `filter`
- Returns: `string`

#### `sort`
- Default: `sort`
- Returns: `string`

#### `fields`
- Default: `fields`
- Returns: `string`

#### `append`
- Default: `append`
- Returns: `string`

#### `page`
- Default: `page`
- Returns: `string`

#### `limit`
- Default: `limit`
- Returns: `string`

## Model Options

These are model-related options.

### `resource`
- Returns: `string`

Resource route of the model which is used to build the query.

See [Configuration](/configuration#creating-the-domain-models)

```js
resource() {
return 'resource'
}
```

### `primaryKey`
- Default: `id`
- Returns: `string`

Primary key of the model which is used to build the query.

See [Configuration](/configuration#changing-the-primary-key)

```js
primaryKey() {
return 'id'
}
```

### `relations`
- Returns: `object`

This method can be implemented in the model to apply model instances to eager loaded relationships.
It works for collections too.

It must return an object, which the key is the property of the relationship, and the value is the
model instance.

See [Configuration](/configuration#eager-loaded-relationships)

```js
relations() {
return {
comments: Comment
}
}
```

### `hasMany`
- Arguments: `(model)`
- Returns: `Model`

This method can be used to lazy load relationships of a model and apply model instances to them.

It must receive a model instance as argument.

See [Configuration](/configuration#lazy-loading-relationships)

```js
comments() {
return this.hasMany(Comment)
}
```
Loading