Files
acms/docs/get-started-cli.md

83 lines
1.8 KiB
Markdown
Raw Normal View History

2024-10-11 14:17:33 +02:00
# Get started with the CLI
## Create a new project
Create a new folder for your project, `my-project`. Change into it, and set `AMCS_CONTENT` to the folder that should store your content.
2024-10-11 15:48:21 +02:00
```console
2024-10-11 14:17:33 +02:00
mkdir -p my-project
cd my-project
export ACMS_CONTENT=$PWD/content
```
2024-10-11 15:48:21 +02:00
## Create a restaurant collection type
2024-10-11 14:17:33 +02:00
2024-10-11 15:48:21 +02:00
```console
2024-10-11 14:17:33 +02:00
acms collection insert restaurant/1.json <<'EOF'
{
2024-10-11 15:48:21 +02:00
"name": "Biscotte Restaurant",
"description": "Welcome to Biscotte restaurant! Restaurant Biscotte offers a cuisine based on fresh, quality products, often local, organic when possible, and always produced by passionate producers."
}
EOF
```
## Create a category collection type
```console
acms collection insert category/1.json <<'EOF'
{
"name": "French Food",
"restaurant": "1.json"
}
EOF
```
```console
acms collection insert category/2.json <<'EOF'
{
"name": "Brunch",
"restaurant": "1.json"
2024-10-11 14:17:33 +02:00
}
EOF
```
2024-10-11 15:48:21 +02:00
## Query the API
```console
curl 'http://localhost:8081' --data '
SELECT
{
name: restaurant.name,
description: restaurant.description,
category: {
category: category.name
}
}
FROM
restaurant
LEFT JOIN
category
ON
category.restaurant == restaurant.$fileName
' | jq .
```
```json
[
{
"category": {
"category": "French Food"
},
"description": "Welcome to Biscotte restaurant! Restaurant Biscotte offers a cuisine based on fresh, quality products, often local, organic when possible, and always produced by passionate producers.",
"name": "Biscotte Restaurant"
},
{
"category": {
"category": "Brunch"
},
"description": "Welcome to Biscotte restaurant! Restaurant Biscotte offers a cuisine based on fresh, quality products, often local, organic when possible, and always produced by passionate producers.",
"name": "Biscotte Restaurant"
}
]
```