{"id":25745999,"url":"https://github.com/cyrix126/diesel_crud_trait","last_synced_at":"2026-06-06T20:31:52.289Z","repository":{"id":221614993,"uuid":"754325627","full_name":"Cyrix126/diesel_crud_trait","owner":"Cyrix126","description":"simple library to implement crud functions on models of diesel.","archived":false,"fork":false,"pushed_at":"2024-02-26T06:48:27.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-26T11:36:50.952Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cyrix126.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-07T20:37:58.000Z","updated_at":"2024-02-09T00:50:36.000Z","dependencies_parsed_at":"2024-02-09T02:14:23.012Z","dependency_job_id":"dca3ef0a-4d90-444a-bdd0-a5e4d9500a14","html_url":"https://github.com/Cyrix126/diesel_crud_trait","commit_stats":null,"previous_names":["cyrix126/diesel_crud_trait"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Cyrix126/diesel_crud_trait","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyrix126%2Fdiesel_crud_trait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyrix126%2Fdiesel_crud_trait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyrix126%2Fdiesel_crud_trait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyrix126%2Fdiesel_crud_trait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cyrix126","download_url":"https://codeload.github.com/Cyrix126/diesel_crud_trait/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cyrix126%2Fdiesel_crud_trait/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285319006,"owners_count":27151474,"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","status":"online","status_checked_at":"2025-11-19T02:00:05.673Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-02-26T11:29:30.273Z","updated_at":"2025-11-19T20:03:31.979Z","avatar_url":"https://github.com/Cyrix126.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# diesel_crud_trait\n\nlibrary to implement [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations on models of diesel in a generic way.\n\nThe goal was to make a generic trait for this, but because it appears to be very complex to put the good trait bounds, I have decided instead to make a simple impl on the model on which the derive macro is applied.\n\n## Disclaimer WIP\n\nThis library is a Work In Progress.\nEverything desscribed in this README are not ready or tested. \n\n## Objectives\n\nThe idea is to make a way to not have to implement CRUD methods to models everytime we write a library making use of diesel.\nThe use of this library must be easy for the dev user.\n\nThis library will bring some functionnality, like optionnaly passing closure with usefull parameter to check input data.\nSimpler method can be called if no check is needed.\n\nA Restful API could be generated from thoses methods, or they could be used directly in an app.\n\n### Features:\n\n#### Derive\n\nBring the derive macro to add the methods easly on your model.\n\n#### Batch\n\nAn implementation for Vec\u003cT\u003e where T: CrudAble allows to use CRUD operation in a batch way.\n\n#### all_methods\n\nAdd methods outside of CRUD method to list or delete all element at once.\n\n## TODO\n\n### Fonctionnality\n\n- [x] defined methods for CRUD operations\n  - [x] create\n  - [x] read\n  - [x] update\n  - [x] delete\n  - [x] possible closure to check provided data before applying operation. \n- [x] add non CRUD usefull operations (all_methods feature)\n  - [x] list all\n  - [x] delete all\n- [ ] implementation for Vec\\\u003cT\\\u003e for using multiples elements (batch feature)\n\n### Other:\n\n- [ ] add tests\n- [ ] add examples\n\n## Usage\n\nYou would apply the derive macro to your model struct.\n\n```rust,ignore\n#[derive(Insertable, CrudAble)]\n  struct Model {\n    rowid: i32,\n    name: String\n  }\n```\n\nAnd then you use the methods of the directly. \n```rust,ignore\nlet value = Model {\n  name: String::from(\"whatever\")\n  ..Default::default()\n};\nvalue.create(conn);\n```\nYou can check the data before the operation occurs.\nYou can pass a Boxed FnMut closure which takes the value and the connection and return a Result\u003c(), ErrorCrude\u003e.\n\n```rust,ignore\nlet check = Box::new(|value: \u0026Model, _conn: \u0026mut SqliteConnection| {\n  if value.name.contains(\"bad word\") {\n    Err(ErrorCrud::InvalidData(\u0026value.name))\n  } else {\n    Ok()\n  }\n});\nfn check_data(value: \u0026Model) -\u003e Result\u003c(), ErrorCrude\u003e {\n}\nvalue.create_after_check(conn, Some(check));\n```\n\n## Licence\n\nGPLv3.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyrix126%2Fdiesel_crud_trait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyrix126%2Fdiesel_crud_trait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyrix126%2Fdiesel_crud_trait/lists"}