{"id":21579588,"url":"https://github.com/hirunya/nosqlite","last_synced_at":"2025-04-10T17:43:28.989Z","repository":{"id":43052669,"uuid":"247440049","full_name":"HiruNya/nosqlite","owner":"HiruNya","description":"A Rusty NoSQL layer over SQLite","archived":false,"fork":false,"pushed_at":"2022-09-06T07:21:48.000Z","size":6439,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-03-06T14:12:27.703Z","etag":null,"topics":["json","nosql","rust","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HiruNya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-15T09:56:38.000Z","updated_at":"2022-01-07T06:50:16.000Z","dependencies_parsed_at":"2023-01-17T21:01:49.288Z","dependency_job_id":null,"html_url":"https://github.com/HiruNya/nosqlite","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiruNya%2Fnosqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiruNya%2Fnosqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiruNya%2Fnosqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HiruNya%2Fnosqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HiruNya","download_url":"https://codeload.github.com/HiruNya/nosqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226165580,"owners_count":17583856,"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":["json","nosql","rust","sqlite"],"created_at":"2024-11-24T13:13:56.170Z","updated_at":"2024-11-24T13:13:56.634Z","avatar_url":"https://github.com/HiruNya.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NoSQLite\n*A Rusty NoSQL layer over SQLite*\n\n![](https://github.com/HiruNya/nosqlite/workflows/Rust/badge.svg)\n[![](https://github.com/HiruNya/nosqlite/workflows/Documentation/badge.svg)](https://hiru.dev/docs/nosqlite/nosqlite/index.html)\n\n[Documentation can be found here.](https://hiru.dev/docs/nosqlite/nosqlite/index.html)\n\nThe intention of this crate is to allow the user to use this library\nas if it was a NoSQL library (e.g. only deal with JSON objects, no schema, etc.)\nbut have the data stored in a SQLite database,\nwhich is a great single-file database.\nIt does this by using SQLite's Json1 extension\nand [`rusqlite`](https://github.com/jgallagher/rusqlite)'s safe bindings.\n\nUnfortunately due to the requirement of parsing and serializing JSON,\nthis crate may not perform as fast as using `SQLite` directly.\nHowever this crate does try to be as ergonomic and flexible as possible.\n\n## Features\n- Insert JSON objects.\n- Get and remove JSON objects by primary key.\n- Iterate through multiple entries in a table.\n- Filter and Sort the entries by using the fields in a JSON object\nor columns in the SQL table.\n- Get *only* the primary key, JSON object,\nor specific field(s) from the JSON object.\n- Set, insert, replace, and remove fields in a JSON object.\n- 'Patch' JSON objects with other JSON objects.\n- Use indexes to speed up queries.\n\n## To Do\n- Set, insert, and replace fields of a single entry using its primary key.\n\n## Example\nThis example can be found in `examples/iterator.rs`\n```rust\n#[derive(Serialize)]\nstruct User {\n\tname: String,\n\tage: u8,\n}\n\nfn main() {\n\tlet connection = Connection::in_memory().unwrap();\n\tlet table = connection.table(\"people\").unwrap();\n\ttable.insert(\u0026User{ name: \"Hiruna\".into(), age: 18 }, \u0026connection).unwrap();\n\ttable.insert(\u0026User{ name: \"Bob\".into(),  age: 13 }, \u0026connection).unwrap();\n\ttable.insert(\u0026User{ name: \"Callum\".into(), age: 25 }, \u0026connection).unwrap();\n\ttable.insert(\u0026User{ name: \"Alex\".into(), age: 20 }, \u0026connection).unwrap();\n\t// Iterate over the entries in the table\n\ttable.iter()\n\t\t// Sort by Age\n\t\t.sort(field(\"age\").ascending())\n\t\t// Only get people who are 18+\n\t\t.filter(field(\"age\").gte(18))\n\t\t// Gets the name and age fields of the JSON object\n\t\t.fields::\u003c(String, u8), _, _, _\u003e(\u0026[\"name\", \"age\"], \u0026connection)\n\t\t.unwrap()\n\t\t.into_iter()\n\t\t.for_each(|(name, age)| println!(\"{:10} : {}\", name, age));\n}\n```\n\n## Installation\nIn your `Cargo.toml` file add this\n```toml\n[dependencies]\nnosqlite = { git = \"https://github.com/HiruNya/nosqlite.git\" }\n```\nThis crate may have breaking changes in its API so I would recommend also adding\nin the specific commit to ensure your code does not break.\n\nI have considered publishing this crate onto [crates.io]\nbut since I'm the only one currently using it I decided against it.\nIf you wish to use this crate and would prefer installing it the normal way using [crates.io]\nthen please don't hesitate in making an issue.\n\n## Inspirations\n[hotpot-db](https://github.com/drbh/hotpot-db)\nwas the original database that used SQLite and its Json1 extension.\nHowever it didn't have certain functions that I needed\nfor a personal project of mine but is still a great crate\ndepending on your use case.\n\n[crates.io]: https://crates.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirunya%2Fnosqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirunya%2Fnosqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirunya%2Fnosqlite/lists"}