{"id":15002764,"url":"https://github.com/ieedan/tiberqueries","last_synced_at":"2025-03-02T20:26:01.195Z","repository":{"id":239837172,"uuid":"800655705","full_name":"ieedan/tiberqueries","owner":"ieedan","description":"A lightweight ORM for Tiberius.","archived":false,"fork":false,"pushed_at":"2024-05-16T12:43:28.000Z","size":32,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T04:48:42.304Z","etag":null,"topics":["derive","mssqlserver","orm","rust","sql","tiberius"],"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/ieedan.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-05-14T18:38:22.000Z","updated_at":"2025-01-17T10:02:20.000Z","dependencies_parsed_at":"2024-05-15T18:14:38.780Z","dependency_job_id":"6379a3e3-3647-49f6-a5e9-b96332727b7b","html_url":"https://github.com/ieedan/tiberqueries","commit_stats":null,"previous_names":["ieedan/tiberqueries"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieedan%2Ftiberqueries","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieedan%2Ftiberqueries/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieedan%2Ftiberqueries/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ieedan%2Ftiberqueries/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ieedan","download_url":"https://codeload.github.com/ieedan/tiberqueries/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241566178,"owners_count":19983260,"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":["derive","mssqlserver","orm","rust","sql","tiberius"],"created_at":"2024-09-24T18:52:21.888Z","updated_at":"2025-03-02T20:26:01.166Z","avatar_url":"https://github.com/ieedan.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tiberqueries\nA lightweight ORM for [Tiberius](https://github.com/prisma/tiberius). \n\nImplements includes derive functionality as well as a trait implementation for the Client. The goal is not to be a query builder and rather to just make mapping your types simple. \n\nIf you are looking for a query builder for SQL Server try [CANYON-SQL](https://github.com/zerodaycode/Canyon-SQL).\n\n## Usage\nAdd `FromRow` to the derive attribute above your struct to automatically generate a `from_row` method on the struct. You can manually map the rows from here or use the `query` feature to extend the client with methods that automatically map the result.\n\nHere we use `FromRow` on an User struct and then select all from the Users table using the `qry` client extension.\n\n```rust\n#[derive(FromRow, Debug)]\npub struct User {\n    pub id: i64,\n    pub username: String,\n    pub email: String,\n    pub picture: String,\n    pub phone_number: Option\u003cString\u003e,\n    pub role_id: i32,\n    pub admin: bool,\n    pub joined: NaiveDateTime\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    /* -- Initialize Client  -- */\n\n    let mut qry = Query::new(\"SELECT * FROM Users\");\n\n    let users: Vec\u003cUser\u003e = client.qry(qry).await?;\n    \n    Ok(())\n}\n```\n\n### Naming\n\nOften your names or casing conventions will be different in your database to your application. When this is the case **tiberqueries** exports a few attributes to make your life easier.\n\n#### to_pascal\nThis converts all members of the struct to **PascalCase**.\n\n```rust\n#[derive(FromRow, Debug)]\n#[to_pascal]\npub struct User {\n    pub id: i64,\n    pub username: String,\n    pub email: String,\n    pub picture: String,\n    pub phone_number: Option\u003cString\u003e,\n    pub role_id: i32,\n    pub admin: bool,\n    pub joined: NaiveDateTime\n}\n\n/* Generated implementation\n\nimpl FromRow for User {\n    fn from_row(row: tiberius::Row) -\u003e Self {\n        use tiberqueries::string;\n        Self {\n            id: row.get(\"Id\").unwrap(),\n            username: string(row.get(\"Username\")).unwrap(),\n            email: string(row.get(\"Email\")).unwrap(),\n            picture: string(row.get(\"Picture\")).unwrap(),\n            phone_number: string(row.get(\"PhoneNumber\")),\n            role_id: row.get(\"RoleId\").unwrap(),\n            admin: row.get(\"Admin\").unwrap(),\n            joined: row.get(\"Joined\").unwrap(),\n        }\n    }\n}\n\n*/\n```\n\n#### sql_name\nThis allows you to specify the name of the field as it appears in SQL. This will override [to_pascal](#to_pascal).\n\n```rust\n#[derive(FromRow)]\npub struct Point {\n    pub x: i32,\n    #[sql_name=\"why\"]\n    pub y: i32,\n}\n\n/*\n\nimpl FromRow for Point {\n    fn from_row(row: tiberius::Row) -\u003e Self {\n        use tiberqueries::string;\n        Self {\n            x: row.get(\"x\").unwrap(),\n            y: row.get(\"why\").unwrap(),\n        }\n    }\n}\n\n*/\n```\n\n#### sql_ignore\nSometimes you need values to be included on your type that aren't mapped to SQL. In this case add `#[sql_ignore=\"true\"]` above the property. You will also need to wrap the type of the property in an `Option\u003c_\u003e` type or you will get an error.\n\n```rust\n#[derive(FromRow)]\npub struct Point {\n    pub x: i32,\n    #[sql_ignore=\"true\"]\n    pub y: Option\u003ci32\u003e,\n}\n\n/*\n\nimpl FromRow for Point {\n    fn from_row(row: tiberius::Row) -\u003e Self {\n        use tiberqueries::string;\n        Self {\n            x: row.get(\"x\").unwrap(),\n            y: None,\n        }\n    }\n}\n\n*/\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fieedan%2Ftiberqueries","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fieedan%2Ftiberqueries","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fieedan%2Ftiberqueries/lists"}