1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00
examples/basics/todo/README.md

49 lines
980 B
Markdown
Raw Normal View History

2022-02-06 08:55:51 +01:00
# Todo
2018-08-27 11:56:26 +02:00
2022-02-06 08:55:51 +01:00
A simple Todo project using a SQLite database.
2018-08-27 11:56:26 +02:00
## Prerequisites
2022-02-06 08:55:51 +01:00
- SQLite 3
2018-08-27 11:56:26 +02:00
2022-02-06 08:55:51 +01:00
## Change Into This Project Sub Directory
2018-08-27 11:56:26 +02:00
All instructions assume you have changed into this folder:
2022-02-18 04:36:04 +01:00
```sh
cd basics/todo
2018-08-27 11:56:26 +02:00
```
2022-02-06 08:55:51 +01:00
## Set Up The Database
2018-08-27 11:56:26 +02:00
2022-02-06 08:55:51 +01:00
Install the [sqlx](https://github.com/launchbadge/sqlx/tree/HEAD/sqlx-cli) command-line tool with the required features:
2018-08-27 11:56:26 +02:00
2022-02-06 08:55:51 +01:00
```sh
cargo install sqlx-cli --no-default-features --features=rustls,sqlite
2018-08-27 11:56:26 +02:00
```
Then to create and set-up the database run:
2022-02-06 08:55:51 +01:00
```sh
2022-02-05 18:34:43 +01:00
sqlx database create
sqlx migrate run
2018-08-27 11:56:26 +02:00
```
2022-02-06 08:55:51 +01:00
## Run The Application
2018-08-27 11:56:26 +02:00
2022-02-06 08:55:51 +01:00
Start the application with:
2018-08-27 11:56:26 +02:00
2022-02-06 08:55:51 +01:00
```sh
2018-08-27 11:56:26 +02:00
cargo run
```
2022-02-06 08:55:51 +01:00
The app will be viewable in the browser at <http://localhost:8080>.
## Modifying The Example Database
For simplicity, this example uses SQLx's offline mode. If you make any changes to the database schema, this must be turned off or the `sqlx-data.json` file regenerated using the following command:
```sh
DATABASE_URL="sqlite://$(pwd)/todo.db" cargo sqlx prepare
```