{"id":23812986,"url":"https://github.com/devashishdxt/rexie","last_synced_at":"2025-04-05T19:12:28.289Z","repository":{"id":37104073,"uuid":"437832039","full_name":"devashishdxt/rexie","owner":"devashishdxt","description":"Rexie is an easy-to-use, futures based wrapper around IndexedDB that compiles to webassembly.","archived":false,"fork":false,"pushed_at":"2024-09-18T05:16:08.000Z","size":84,"stargazers_count":87,"open_issues_count":1,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T17:11:16.459Z","etag":null,"topics":[],"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/devashishdxt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-13T10:38:09.000Z","updated_at":"2025-03-23T08:54:10.000Z","dependencies_parsed_at":"2024-06-21T14:28:02.616Z","dependency_job_id":"f56e3bdd-cbaa-4cce-b446-e87649c161e2","html_url":"https://github.com/devashishdxt/rexie","commit_stats":{"total_commits":36,"total_committers":5,"mean_commits":7.2,"dds":"0.13888888888888884","last_synced_commit":"c6bce1961d101b74b92a01e87f128cbfafa43655"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Frexie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Frexie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Frexie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devashishdxt%2Frexie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devashishdxt","download_url":"https://codeload.github.com/devashishdxt/rexie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247386265,"owners_count":20930619,"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":[],"created_at":"2025-01-02T02:39:18.417Z","updated_at":"2025-04-05T19:12:28.269Z","avatar_url":"https://github.com/devashishdxt.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# rexie\n\nRexie is an easy-to-use, futures based wrapper around IndexedDB that compiles to webassembly.\n\n## Usage\n\nTo use Rexie, you need to add the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nrexie = \"0.6\"\n```\n\n### Example\n\nTo create a new database, you can use the [`Rexie::builder`] method:\n\n```rust\nuse rexie::*;\n\nasync fn build_database() -\u003e Result\u003cRexie\u003e {\n   // Create a new database\n   let rexie = Rexie::builder(\"test\")\n       // Set the version of the database to 1.0\n       .version(1)\n       // Add an object store named `employees`\n       .add_object_store(\n           ObjectStore::new(\"employees\")\n               // Set the key path to `id`\n               .key_path(\"id\")\n               // Enable auto increment\n               .auto_increment(true)\n               // Add an index named `email` with the key path `email` with unique enabled\n               .add_index(Index::new(\"email\", \"email\").unique(true)),\n       )\n       // Build the database\n       .build()\n       .await?;\n\n    // Check basic details of the database\n    assert_eq!(rexie.name(), \"test\");\n    assert_eq!(rexie.version(), Ok(1));\n    assert_eq!(rexie.store_names(), vec![\"employees\"]);\n\n    Ok(rexie)\n}\n```\n\nTo add an employee, you can use the [`Store::add`] method after creating a [`Transaction`]:\n\n```rust\nuse rexie::*;\n\nasync fn add_employee(rexie: \u0026Rexie, name: \u0026str, email: \u0026str) -\u003e Result\u003cu32\u003e {\n    // Create a new read-write transaction\n    let transaction = rexie.transaction(\u0026[\"employees\"], TransactionMode::ReadWrite)?;\n\n    // Get the `employees` store\n    let employees = transaction.store(\"employees\")?;\n\n    // Create an employee\n    let employee = serde_json::json!({\n        \"name\": name,\n        \"email\": email,\n    });\n    // Convert it to `JsValue`\n    let employee = serde_wasm_bindgen::to_value(\u0026employee).unwrap();\n\n    // Add the employee to the store\n    let employee_id = employees.add(\u0026employee, None).await?;\n\n    // Waits for the transaction to complete\n    transaction.done().await?;\n\n    // Return the employee id\n    Ok(num_traits::cast(employee_id.as_f64().unwrap()).unwrap())\n}\n```\n\nTo get an employee, you can use the [`Store::get`] method after creating a [`Transaction`]:\n\n```rust\nuse rexie::*;\n\nasync fn get_employee(rexie: \u0026Rexie, id: u32) -\u003e Result\u003cOption\u003cserde_json::Value\u003e\u003e {\n    // Create a new read-only transaction\n    let transaction = rexie.transaction(\u0026[\"employees\"], TransactionMode::ReadOnly)?;\n\n    // Get the `employees` store\n    let employees = transaction.store(\"employees\")?;\n\n    // Get the employee\n    let employee = employees.get(id.into()).await?.unwrap();\n\n    // Convert it to `serde_json::Value` from `JsValue`\n    let employee: Option\u003cserde_json::Value\u003e = serde_wasm_bindgen::from_value(employee).unwrap();\n\n    // Return the employee\n    Ok(employee)\n}\n```\n\n## License\n\nLicensed under either of\n\n- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))\n- MIT license ([LICENSE-MIT](LICENSE-MIT))\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as\ndefined 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%2Fdevashishdxt%2Frexie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevashishdxt%2Frexie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevashishdxt%2Frexie/lists"}