2020-11-12 07:21:54 -08:00

42 lines
515 B
Markdown

# JSON Example
## Setup
1. Declare the database URL
```
export DATABASE_URL="postgres://postgres:password@localhost/json"
```
2. Create the database.
```
$ sqlx db create
```
3. Run sql migrations
```
$ sqlx migrate run
```
## Usage
Add a person
```
echo '{ "name": "John Doe", "age": 30 }' | cargo run -- add
```
or with extra keys
```
echo '{ "name": "Jane Doe", "age": 25, "array": ["string", true, 0] }' | cargo run -- add
```
List all people
```
cargo run
```