mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-11-01 14:02:46 +00:00
749 B
749 B
Mockable TODOs Example
Description
This example is based on the ideas in this blog post. The value here is that the business logic can be unit tested independently from the database layer. Otherwise it is identical to the todos example.
Setup
-
Declare the database URL
export DATABASE_URL="postgres://postgres:password@localhost/todos" -
Create the database.
$ sqlx db create -
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