DDD without repository pattern, see [https://softwareengineering.stackexchange.com/questions/441348/in-the-oo-ddd-does-the-domain-object-access-the-repository-directly]
-
Create .env file if needed. Run
docker-compose up -d
to run Postgres in the background. -
Declare the database URL
export DATABASE_URL="postgres://postgres:password@localhost/users"
Access from command line like:
psql postgresql://postgres:password@localhost/users -c 'select * from users'
-
Create the database.
sqlx db create
-
Run sql migrations
sqlx migrate run
cargo run
psql postgresql://postgres:password@localhost/users -c 'select * from users'