{"id":20622554,"url":"https://github.com/andy-python-programmer/dino","last_synced_at":"2025-04-15T12:33:52.863Z","repository":{"id":57619473,"uuid":"305045800","full_name":"Andy-Python-Programmer/dino","owner":"Andy-Python-Programmer","description":"Dino is a lightweight and fast database for rust!","archived":false,"fork":false,"pushed_at":"2021-01-21T22:26:53.000Z","size":72,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T22:29:07.706Z","etag":null,"topics":["database","hacktoberfest","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Andy-Python-Programmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-18T07:23:11.000Z","updated_at":"2024-05-08T01:08:51.000Z","dependencies_parsed_at":"2022-09-16T18:50:10.923Z","dependency_job_id":null,"html_url":"https://github.com/Andy-Python-Programmer/dino","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andy-Python-Programmer%2Fdino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andy-Python-Programmer%2Fdino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andy-Python-Programmer%2Fdino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Andy-Python-Programmer%2Fdino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Andy-Python-Programmer","download_url":"https://codeload.github.com/Andy-Python-Programmer/dino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249072722,"owners_count":21208234,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","hacktoberfest","rust"],"created_at":"2024-11-16T12:23:26.804Z","updated_at":"2025-04-15T12:33:52.843Z","avatar_url":"https://github.com/Andy-Python-Programmer.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dino\n\n![Crates.io](https://github.com/Andy-Python-Programmer/dino/workflows/Build/badge.svg)\n![Crates.io](https://img.shields.io/crates/d/dino)\n![Crates.io](https://img.shields.io/crates/v/dino)\n![Crates.io](https://docs.rs/dino/badge.svg)\n\n`Dino` is a lightweight database for rust!\nIt makes writing databases with types more easy.\nNormally if you use a File Storage database then you will have to parse the types by yourself\n\nDino uses json ie. You will have all of the basic types like [bool](https://doc.rust-lang.org/nightly/std/primitive.bool.html), [usize](https://doc.rust-lang.org/nightly/std/primitive.usize.html), [str](https://doc.rust-lang.org/nightly/std/primitive.str.html), etc... and the special one is Tree.\nDino is special about trees. Because some of the databases allow you to open trees but you cannot open sub trees there.\nYou can P easily open a sub tree. Here are some of the examples that show how to use trees and how to use the database without sub trees ;)\n\n## Example Code\n\n### Basic Database\n\n```rust\n// Create the database instance\nlet mut db = Database::new(\"./basic.dino\");\n\n// Load and create the database if does not exist\ndb.load();\n\n// Insert values in the db in the format of key, value\ndb.insert(\"key-1\", \"value-1\");\ndb.insert(\"key-2\", \"value-2\");\n```\n\n### Sub Trees\n\n```rust\n// Create the database instance\nlet mut db = Database::new(\"./sub_trees.dino\");\n\n// Load and create the database if does not exist\ndb.load();\n\n// Create a new sub Tree in the main Tree of the db\nlet mut data_tree = Tree::new();\n\n// Insert the key and value in the sub tree\ndata_tree.insert(\"a\", \"b\");\n\n// Insert the [data_tree] under the main tree\ndb.insert_tree(\"id\", data_tree);\n```\n\n### Querying the Database\n\n```rust\n// Create the database instance\nlet mut db = Database::new(\"./basic.dino\");\n\n// Load and create the database if does not exist\ndb.load();\n\n// Insert values in the db in the format of key, value\ndb.insert(\"key-1\", \"value-1\");\n\n// Print the value of `key-1`\nprintln!(\"The value of key: id is {}\", db.find(\"key-1\").unwrap());\n```\n\n### Using it with [rocket.rs](https://crates.io/crates/rocket)\n\n```rust\n// Simple rocket route\n#[get(\"/\u003cid\u003e\")]\n// Here we add the arg `db: State\u003cdino::Database\u003e`\n// To get the db state that we passed before!\nfn hello(db: State\u003cdino::Database\u003e, id: String) -\u003e String {\n    // Now in this rocket route we take a id param\n    // We will extract the param to str\n    // Then check if it exists\n    match db.find(id.as_str()) {\n        // If it exists it will return Ok(value)\n        Ok(value) =\u003e {\n            // Then we can return the value!\n            return value.to_string();\n        }\n\n        // If it does not exists it gives a error\n        Err(error) =\u003e {\n            // So return the error!\n            // You might want to handle the error too!\n            return error;\n        }\n    }\n}\n\nfn main() {\n    // Create the database instance\n    let mut db = dino::Database::new(\"rocket.dino\");\n\n    // Load and create the database if does not exist\n    db.load();\n\n    // Insert a key with a dummy value for now!\n    db.insert(\"key\", \"value!\");\n\n    // Ignite the rocket and mount the routes\n    rocket::ignite()\n        .mount(\"/\", routes![hello])\n        // Important part here!\n        // Here we pass the db state to rocket\n        // So we can access it when we go to any route.\n        .manage(db)\n        .launch();\n}\n```\n\nThere is a lot more for you to explore! So check out the [docs](https://docs.rs/dino/0.1.2/dino/index.html) and the [examples](https://github.com/Andy-Python-Programmer/dino/tree/master/examples) directory.\n\n## Contributing\nContributions are always welcome! Here are some ways you can contribute to dino:\n\n1. File issues and buggs\n2. Help us with documentation\n3. Add new features in dino and fix buggs!\n\n## License\nLicensed under either of Apache License, Version 2.0 or MIT license at your option.\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy-python-programmer%2Fdino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy-python-programmer%2Fdino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy-python-programmer%2Fdino/lists"}