Skip to content

Commit c362fde

Browse files
committed
update readme
1 parent 1af4f80 commit c362fde

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

README.md

+39-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
1-
# rust-db-adapter
2-
Rust adapter to the database. Provides models and methods to interact with it.
3-
Rust DB wrapper
1+
# db-adapter
42

5-
This crate provides models and methods to interact with teh databse by using rust's typesystem. The crate should provide methods for all allowed interactions with the database. It conviniently wraps around the structure by enforcin the invariants by itself.
3+
A wrapper around Botanist database scheme
4+
5+
## Objective
6+
7+
This crate was built with the intent to provide a safe wrapper around Botanist's
8+
database scheme. This way invariants remain true at all times, no other tool can
9+
mess the data in an incorrect way.
10+
11+
Centralizing the interactions with the database also allows finer control over
12+
iterations of its scheme. On that note changes in the scheme are done through migrations scripts
13+
(see the `migrations`) folder. Hence the setup of the databse is made very simple with
14+
[`sqlx`'s cli tool]. Moreover deviations from the scheme provided by the migration scripts
15+
will be detected by the tests (see `tests/framework` and [migrate]).
16+
17+
Finally providing a rust library allows [db_adapter] to provide useful abstractions.
18+
19+
## Setup
20+
Setup is intended to be as simple as possible so if you find some way to simplify a step please open
21+
an issue.
22+
First of all make sure you have a posgresql database up and running. Search online for walkthroughs
23+
if you don't know how. Then rename `.env-example` to `.env` and enter make sure you place your values
24+
in it.
25+
Now install [sqlx-cli] and run the migrations using `sqlx migrate run`. If you set up the DB and `.env`
26+
correctly you should be good to go!
27+
If you're only using the library you don't need to do anuything else but you could still
28+
run the tests just in case: `cargo t`.
29+
30+
## Developement
31+
32+
To contribute to [db_adapter] you should setup the test environement. In addition to the previous section's
33+
steps you should setup another DB for the tests and refer it in `.env`. From there you can dive in the code!
34+
Just make sure you don't break any invariants and remember to respect semver. You are also expected
35+
to document and tests any item added to the public API.
36+
37+
[sqlx-cli]: https://github.com/launchbadge/sqlx/tree/master/sqlx-cli
38+
[`sqlx`'s cli tool]: https://github.com/launchbadge/sqlx/tree/master/sqlx-cli
39+
[db_adapter]: https://github.com/Botanism/rust-db-adapter/
40+
[migrate]: https://docs.rs/sqlx/0.5.5/sqlx/migrate/index.html

0 commit comments

Comments
 (0)