This example is a sapper app, with diesel as its orm.
This example contains:
- A model Blog;
- CRUD on Blog;
- simple front web pages.
This example is designed to demostrate some sapper's abilities:
- global wrapper (app middleware);
- module;
- module middleware;
- router;
- global (cross requests) shared object without unsafe;
- orm;
- orm codegen;
- create/drop db table from command;
- template rendering;
- helper macros;
- redirection;
First, you need install postgresql (I tested it on postgresql 9.4).
Modify .env file in the root of this example, my setting is like this:
DATABASE_URL=postgres://postgres:123456@localhost/sapper_diesel
You should modify this line to your own config.
After setting db config, run
cargo install diesel_cli
In root of this example, run
diesel setup
This will create our database (if it didn't already exist), and create an empty migrations directory that we can use to manage our schema.
In root of this example, run
diesel migration run
This step will create blogs table in your db.
run
cargo run
to run this example. It will listen on http://127.0.0.1:1337.
Open http://127.0.0.1:1337 to play.
Good luck! :)