2022-05-19 00:40:55 +08:00
|
|
|
|
# Action API
|
|
|
|
|
|
|
|
|
|
## Common
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
|
Collection and Association resources are common.
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
|
|
### `create`
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
POST /api/users:create?whitelist=a,b&blacklist=c,d
|
|
|
|
|
|
|
|
|
|
{} # Request Body
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- Parameters
|
2022-10-31 23:20:27 +08:00
|
|
|
|
- whitelist White list
|
|
|
|
|
- blacklist Black list
|
|
|
|
|
- Request body: JSON data to be inserted
|
|
|
|
|
- Response body data: Created data JSON
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
|
#### Add a User
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
POST /api/users:create
|
|
|
|
|
|
|
|
|
|
Request Body
|
|
|
|
|
{
|
|
|
|
|
"email": "demo@nocobase.com",
|
|
|
|
|
"name": "Admin"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Response 200 (application/json)
|
|
|
|
|
{
|
|
|
|
|
"data": {},
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
|
#### Add a user's article
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
POST /api/users/1/posts:create
|
|
|
|
|
|
|
|
|
|
Request Body
|
|
|
|
|
{
|
|
|
|
|
"title": "My first post"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Response 200 (application/json)
|
|
|
|
|
{
|
2022-10-31 23:20:27 +08:00
|
|
|
|
"data": {},
|
2022-05-19 00:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
|
#### Association in Request Body
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
POST /api/posts:create
|
|
|
|
|
|
|
|
|
|
Request Body
|
|
|
|
|
{
|
|
|
|
|
"title": "My first post",
|
|
|
|
|
"user": 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Response 200 (application/json)
|
|
|
|
|
{
|
|
|
|
|
"data": {
|
|
|
|
|
"id": 1,
|
|
|
|
|
"title": "My first post",
|
|
|
|
|
"userId": 1,
|
|
|
|
|
"user": {
|
|
|
|
|
"id": 1
|
|
|
|
|
}
|
2022-05-27 00:00:59 +08:00
|
|
|
|
}
|
2022-05-19 00:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `update`
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
POST /api/users:create?filterByTk=1&whitelist=a,b&blacklist=c,d
|
|
|
|
|
|
|
|
|
|
{} # Request Body
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- Parameters
|
2022-10-31 23:20:27 +08:00
|
|
|
|
- whitelist White list
|
|
|
|
|
- blacklist Black list
|
|
|
|
|
- filterByTk Filter by tk field, by default tk is the primary key of the data table
|
|
|
|
|
- filter Filter,support json string
|
|
|
|
|
- Request body: JSON data to be updated
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
2022-10-31 23:20:27 +08:00
|
|
|
|
#### Association in Request Body
|
2022-05-19 00:40:55 +08:00
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
POST /api/posts:update/1
|
|
|
|
|
|
|
|
|
|
Request Body
|
|
|
|
|
{
|
|
|
|
|
"title": "My first post 2",
|
|
|
|
|
"user": 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Response 200 (application/json)
|
|
|
|
|
{
|
|
|
|
|
"data": [
|
|
|
|
|
{
|
|
|
|
|
"id": 1,
|
|
|
|
|
"title": "My first post 2",
|
|
|
|
|
"userId": 2,
|
|
|
|
|
"user": {
|
|
|
|
|
"id": 2
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-27 00:00:59 +08:00
|
|
|
|
]
|
2022-05-19 00:40:55 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `list`
|
|
|
|
|
|
|
|
|
|
### `get`
|
|
|
|
|
|
|
|
|
|
### `destroy`
|
|
|
|
|
|
|
|
|
|
### `move`
|
|
|
|
|
|
|
|
|
|
## Association
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
### `add`
|
|
|
|
|
|
|
|
|
|
### `set`
|
|
|
|
|
|
|
|
|
|
### `remove`
|
|
|
|
|
|
|
|
|
|
### `toggle`
|
2022-10-31 23:20:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|