mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-27 03:25:08 +00:00
42 lines
427 B
Markdown
42 lines
427 B
Markdown
# TODOs Example
|
|
|
|
## Setup
|
|
|
|
1. Declare the database URL
|
|
|
|
```
|
|
export DATABASE_URL="postgres://postgres:password@localhost/todos"
|
|
```
|
|
|
|
2. Create the database.
|
|
|
|
```
|
|
$ sqlx db create
|
|
```
|
|
|
|
3. Run sql migrations
|
|
|
|
```
|
|
$ sqlx migrate run
|
|
```
|
|
|
|
## Usage
|
|
|
|
Add a todo
|
|
|
|
```
|
|
cargo run -- add "todo description"
|
|
```
|
|
|
|
Complete a todo.
|
|
|
|
```
|
|
cargo run -- done <todo id>
|
|
```
|
|
|
|
List all todos
|
|
|
|
```
|
|
cargo run
|
|
```
|