-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
3 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Welcome to njord! Commands mkdocs new [dir-name] - Create a new project. mkdocs serve - Start the live-reloading docs server. mkdocs build - Build the documentation site. mkdocs -h - Print help message and exit. Project layout mkdocs.yml # The configuration file. docs/ index.md # The documentation homepage. ... # Other markdown pages, images and other files.","title":"Home"},{"location":"#welcome-to-njord","text":"","title":"Welcome to njord!"},{"location":"#commands","text":"mkdocs new [dir-name] - Create a new project. mkdocs serve - Start the live-reloading docs server. mkdocs build - Build the documentation site. mkdocs -h - Print help message and exit.","title":"Commands"},{"location":"#project-layout","text":"mkdocs.yml # The configuration file. docs/ index.md # The documentation homepage. ... # Other markdown pages, images and other files.","title":"Project layout"},{"location":"get_started/","text":"Get started To install njord into your Rust project we need to include the dependencies: Cargo.toml [dependencies] # The core APIs, including the Table trait. Always # required when using njord. The \"derive\" feature is only required when # using #[derive(Table)] to make njord work with structs # and enums defined in your crate. njord = { version = \"0.1.0\", features = [\"derive\"] }","title":"GetStarted"},{"location":"get_started/#get-started","text":"To install njord into your Rust project we need to include the dependencies: Cargo.toml [dependencies] # The core APIs, including the Table trait. Always # required when using njord. The \"derive\" feature is only required when # using #[derive(Table)] to make njord work with structs # and enums defined in your crate. njord = { version = \"0.1.0\", features = [\"derive\"] }","title":"Get started"},{"location":"sqlite/","text":"Sqlite Setup connection First thing you need to do is to setup a connection is: let conn = sqlite::open(\"my_database.db\"); We can also use a in-memory database: let conn = sqlite::open_in_memory(\"my_database.db\"); Define tables To define a table we use derive with the Table (provided by njord) and Default procedural macro. Then we create a simple struct with a given name. The name of the struct will be the table name in the database: #[derive(Table, Default)] struct Posts { title: String, description: String, } #[derive(Table, Default)] struct Categories { name: String, } Initialize database with tables First thing we need to do before we do any insert , select etc is to initialize the database with the defined tables. To initialize the database we need to box the struct and call default() and save it to a variable: let posts_table = Box::<Posts>::default(); let categories_table = Box::<Categories>::default(); Now we add them to a tables vector: let mut tables: Vec<Box<dyn Table>> = vec![posts_table, categories_table]; Lastly, we call the init() function to setup the tables from the tables vector, such as: sqlite::init(conn, tables); Insert data to table To insert data, we need to initialize our Posts struct that we created with values for each field: let table_row: Posts = Posts { title: \"A post title\".to_string(), description: \"Some description for for a post\".to_string(), }; We insert the row by passing a connection and a reference to the table_row: sqlite::insert(conn, &table_row); Drop table To drop a table, it is a simple as: sqlite::drop_table(conn, &Posts::default()); Select Docs are coming soon... WHERE ORDER BY GROUP BY LIMIT OFFSET","title":"Sqlite"},{"location":"sqlite/#sqlite","text":"","title":"Sqlite"},{"location":"sqlite/#setup-connection","text":"First thing you need to do is to setup a connection is: let conn = sqlite::open(\"my_database.db\"); We can also use a in-memory database: let conn = sqlite::open_in_memory(\"my_database.db\");","title":"Setup connection"},{"location":"sqlite/#define-tables","text":"To define a table we use derive with the Table (provided by njord) and Default procedural macro. Then we create a simple struct with a given name. The name of the struct will be the table name in the database: #[derive(Table, Default)] struct Posts { title: String, description: String, } #[derive(Table, Default)] struct Categories { name: String, }","title":"Define tables"},{"location":"sqlite/#initialize-database-with-tables","text":"First thing we need to do before we do any insert , select etc is to initialize the database with the defined tables. To initialize the database we need to box the struct and call default() and save it to a variable: let posts_table = Box::<Posts>::default(); let categories_table = Box::<Categories>::default(); Now we add them to a tables vector: let mut tables: Vec<Box<dyn Table>> = vec![posts_table, categories_table]; Lastly, we call the init() function to setup the tables from the tables vector, such as: sqlite::init(conn, tables);","title":"Initialize database with tables"},{"location":"sqlite/#insert-data-to-table","text":"To insert data, we need to initialize our Posts struct that we created with values for each field: let table_row: Posts = Posts { title: \"A post title\".to_string(), description: \"Some description for for a post\".to_string(), }; We insert the row by passing a connection and a reference to the table_row: sqlite::insert(conn, &table_row);","title":"Insert data to table"},{"location":"sqlite/#drop-table","text":"To drop a table, it is a simple as: sqlite::drop_table(conn, &Posts::default());","title":"Drop table"},{"location":"sqlite/#select","text":"Docs are coming soon...","title":"Select"},{"location":"sqlite/#where","text":"","title":"WHERE"},{"location":"sqlite/#order-by","text":"","title":"ORDER BY"},{"location":"sqlite/#group-by","text":"","title":"GROUP BY"},{"location":"sqlite/#limit","text":"","title":"LIMIT"},{"location":"sqlite/#offset","text":"","title":"OFFSET"}]} | ||
{"config":{"indexing":"full","lang":["en"],"min_search_length":3,"prebuild_index":false,"separator":"[\\s\\-]+"},"docs":[{"location":"","text":"Welcome to njord! A lightweight ORM library for Rust with strong-typed SQL DSL and sequence APIs.","title":"Home"},{"location":"#welcome-to-njord","text":"A lightweight ORM library for Rust with strong-typed SQL DSL and sequence APIs.","title":"Welcome to njord!"},{"location":"get_started/","text":"Get started To install njord into your Rust project we need to include the dependencies: Cargo.toml [dependencies] # The core APIs, including the Table trait. Always # required when using njord. The \"derive\" feature is only required when # using #[derive(Table)] to make njord work with structs # and enums defined in your crate. njord = { version = \"0.1.0\", features = [\"derive\"] }","title":"GetStarted"},{"location":"get_started/#get-started","text":"To install njord into your Rust project we need to include the dependencies: Cargo.toml [dependencies] # The core APIs, including the Table trait. Always # required when using njord. The \"derive\" feature is only required when # using #[derive(Table)] to make njord work with structs # and enums defined in your crate. njord = { version = \"0.1.0\", features = [\"derive\"] }","title":"Get started"},{"location":"sqlite/","text":"Sqlite Setup connection First thing you need to do is to setup a connection is: let conn = sqlite::open(\"my_database.db\"); We can also use a in-memory database: let conn = sqlite::open_in_memory(\"my_database.db\"); Define tables To define a table we use derive with the Table (provided by njord) and Default procedural macro. Then we create a simple struct with a given name. The name of the struct will be the table name in the database: #[derive(Table, Default)] struct Posts { title: String, description: String, } #[derive(Table, Default)] struct Categories { name: String, } Initialize database with tables First thing we need to do before we do any insert , select etc is to initialize the database with the defined tables. To initialize the database we need to box the struct and call default() and save it to a variable: let posts_table = Box::<Posts>::default(); let categories_table = Box::<Categories>::default(); Now we add them to a tables vector: let mut tables: Vec<Box<dyn Table>> = vec![posts_table, categories_table]; Lastly, we call the init() function to setup the tables from the tables vector, such as: sqlite::init(conn, tables); Insert data to table To insert data, we need to initialize our Posts struct that we created with values for each field: let table_row: Posts = Posts { title: \"A post title\".to_string(), description: \"Some description for for a post\".to_string(), }; We insert the row by passing a connection and a reference to the table_row: sqlite::insert(conn, &table_row); Drop table To drop a table, it is a simple as: sqlite::drop_table(conn, &Posts::default()); Select Docs are coming soon... WHERE ORDER BY GROUP BY LIMIT OFFSET","title":"Sqlite"},{"location":"sqlite/#sqlite","text":"","title":"Sqlite"},{"location":"sqlite/#setup-connection","text":"First thing you need to do is to setup a connection is: let conn = sqlite::open(\"my_database.db\"); We can also use a in-memory database: let conn = sqlite::open_in_memory(\"my_database.db\");","title":"Setup connection"},{"location":"sqlite/#define-tables","text":"To define a table we use derive with the Table (provided by njord) and Default procedural macro. Then we create a simple struct with a given name. The name of the struct will be the table name in the database: #[derive(Table, Default)] struct Posts { title: String, description: String, } #[derive(Table, Default)] struct Categories { name: String, }","title":"Define tables"},{"location":"sqlite/#initialize-database-with-tables","text":"First thing we need to do before we do any insert , select etc is to initialize the database with the defined tables. To initialize the database we need to box the struct and call default() and save it to a variable: let posts_table = Box::<Posts>::default(); let categories_table = Box::<Categories>::default(); Now we add them to a tables vector: let mut tables: Vec<Box<dyn Table>> = vec![posts_table, categories_table]; Lastly, we call the init() function to setup the tables from the tables vector, such as: sqlite::init(conn, tables);","title":"Initialize database with tables"},{"location":"sqlite/#insert-data-to-table","text":"To insert data, we need to initialize our Posts struct that we created with values for each field: let table_row: Posts = Posts { title: \"A post title\".to_string(), description: \"Some description for for a post\".to_string(), }; We insert the row by passing a connection and a reference to the table_row: sqlite::insert(conn, &table_row);","title":"Insert data to table"},{"location":"sqlite/#drop-table","text":"To drop a table, it is a simple as: sqlite::drop_table(conn, &Posts::default());","title":"Drop table"},{"location":"sqlite/#select","text":"Docs are coming soon...","title":"Select"},{"location":"sqlite/#where","text":"","title":"WHERE"},{"location":"sqlite/#order-by","text":"","title":"ORDER BY"},{"location":"sqlite/#group-by","text":"","title":"GROUP BY"},{"location":"sqlite/#limit","text":"","title":"LIMIT"},{"location":"sqlite/#offset","text":"","title":"OFFSET"}]} |
Binary file not shown.