[{"data":1,"prerenderedAt":2000},["ShallowReactive",2],{"$fDfoT2PeVahRshwTJWcSTwUQj0CzDnEnEnm_hMFkyaP8":3},{"slug":4,"title":5,"description":6,"source":7,"document":8,"toc":1980,"editUrl":1994,"prev":1995,"next":1998},"techniques\u002Fdatabase","Database (ORM)","Persist entities with the ORM abstraction, Repository\u003CT>, and the in-memory and Sea adapters.","---\ntitle: Database (ORM)\ndescription: Persist entities with the ORM abstraction, Repository\u003CT>, and the in-memory and Sea adapters.\n---\n\n# Database (ORM)\n\nFerrite's ORM is a thin, focused abstraction: define an **entity**, pick a **store** adapter, inject a `Repository\u003CE>`, and get CRUD. It stays deliberately small — no unit-of-work, no implicit change tracking, no relations. Everything is explicit and type-checked.\n\n## Entities\n\nDefine an entity as a plain struct with `serde` derives:\n\n```rust\nuse serde::{Deserialize, Serialize};\nuse ferrite_framework::entity;\n\n#[derive(Debug, Clone, Serialize, Deserialize)]\n#[entity(table = \"users\", primary_key = \"id\")]\npub struct User {\n    pub id: i64,\n    pub email: String,\n    pub name: String,\n    pub age: i32,\n}\n```\n\nThe macro generates the `Entity` impl:\n\n```rust\npub trait Entity: Clone + Send + Sync + 'static {\n    type PrimaryKey: Clone + PartialEq + fmt::Debug + fmt::Display + Send + Sync + 'static;\n    fn table_name() -> &'static str;\n    fn primary_key(&self) -> Self::PrimaryKey;\n}\n```\n\n| Option | Default | Notes |\n| --- | --- | --- |\n| `table` | struct name | e.g. `users` |\n| `primary_key` | `\"id\"` | the field must exist |\n| `store` | `::ferrite_framework::orm::InMemoryPick` | which picker builds the store |\n\n## Repositories\n\n`#[entity]` registers `Repository\u003CE>` as a DI provider automatically:\n\n```rust\nimpl\u003CE: Entity> Repository\u003CE> {\n    pub async fn find_all(&self) -> Result\u003CVec\u003CE>, OrmError>;\n    pub async fn find_by_pk(&self, pk: E::PrimaryKey) -> Result\u003COption\u003CE>, OrmError>;\n    pub async fn save(&self, entity: &E) -> Result\u003C(), OrmError>;\n    pub async fn delete(&self, pk: &E::PrimaryKey) -> Result\u003Cbool, OrmError>;\n}\n```\n\nInject it wherever you need it:\n\n```rust\n#[injectable]\npub struct UsersService {\n    users: Repository\u003CUser>,\n}\n\nimpl UsersService {\n    #[inject]\n    pub fn new(users: Repository\u003CUser>) -> Self {\n        Self { users }\n    }\n\n    pub async fn find(&self, id: i64) -> Result\u003COption\u003CUser>, OrmError> {\n        self.users.find_by_pk(id).await\n    }\n}\n```\n\n### The contract\n\nThe runtime is described by two traits, so adapters are swappable:\n\n```rust\n#[async_trait]\npub trait Store\u003CE: Entity>: Send + Sync + 'static {\n    async fn find_all(&self) -> Result\u003CVec\u003CE>, OrmError>;\n    async fn find_by_pk(&self, pk: &str) -> Result\u003COption\u003CE>, OrmError>;  \u002F\u002F stringified key (object-safe)\n    async fn save(&self, entity: &E) -> Result\u003C(), OrmError>;\n    async fn delete(&self, pk: &str) -> Result\u003Cbool, OrmError>;\n}\n\npub trait Pick\u003CE: Entity>: Send + Sync + 'static {\n    fn build(&self) -> Arc\u003Cdyn Store\u003CE>>;\n}\n```\n\n`OrmError` has three shapes: `NotFound`, `Key(String)`, `Backend(String)`.\n\n## The adapters\n\n| Adapter | Crate | Status |\n| --- | --- | --- |\n| In-memory | `ferrite-orm` (`InMemoryPick`) | **Works** — global provider, zero setup |\n| Sea | `ferrite-orm-sea` (`SeaPick`) | **Works** — full `Store` + `ModelEntity` bridge, migrations harness |\n| SQLx | `ferrite-orm-sqlx` (`SqlxPick`) | **Stub** — provider registered, no `Pick\u003CE>` impl yet |\n| Diesel | `ferrite-orm-diesel` (`DieselPick`) | **Stub** — provider registered, no `Pick\u003CE>` impl yet |\n\n### In-memory (default)\n\nSave an entity with `store` omitted:\n\n```rust\n#[entity]\npub struct Note { pub id: i64, pub body: String }\n```\n\n`InMemoryPick` is a global singleton, so `Repository\u003CNote>` resolves without any module import. It's perfect for tests, prototypes, and the scaffolded examples.\n\n### SeaORM\n\nPick the Sea adapter with an explicit `store`:\n\n```rust\n#[entity(table = \"users\", primary_key = \"id\", store = \"ferrite_orm_sea::SeaPick\")]\npub struct User { \u002F* ... *\u002F }\n```\n\n`SeaPick` requires `E: Entity + ModelEntity + FromQueryResult`. It validates the `DATABASE_URL` scheme and feature flags:\n\n| Feature | Schemes |\n| --- | --- |\n| `sqlite` | `sqlite:`, `sqlite:\u002F\u002F` (default `sqlite::memory:`) |\n| `postgres` | `postgres:\u002F\u002F`, `postgresql:\u002F\u002F` |\n| `mysql` | `mysql:\u002F\u002F` |\n\nConfigure `ferrite-orm-sea` in your `Cargo.toml`:\n\n```toml\nferrite-orm-sea = { version = \"=0.1.0\", features = [\"postgres\"] }\n```\n\n### Coming soon: SQLx & Diesel\n\nThe `SqlxPick` \u002F `DieselPick` providers and `SqlxStore\u003CE>` \u002F `DieselStore\u003CE>` constructors exist, but the `Pick\u003CE>` \u002F `Store\u003CE>` impls are not wired yet. If you try to use them today you'll get a compiler error — the docs will be updated when the adapters land.\n\n## Migrations\n\n`ferrite-orm-sea` ships a full migrations harness driven by the CLI:\n\n```bash\nfr db migrate-create add_users_table\n```\n\nCreates `migrations\u002F\u003Ctimestamp>_add_users_table\u002F{up.sql,down.sql}`. Then:\n\n```bash\nfr db migrate    # applies pending migrations (records in __ferrite_migrations)\nfr db revert     # rolls back the last applied\nfr db seed       # runs seeds\u002F*.sql\nfr db status     # applied vs pending report\n```\n\nThe harness honors `FERRITE_DB_ACTION` and runs via the app binary, so your app's exact connection config drives it.\n\n## A repository-heavy example\n\n```rust\n#[derive(Debug, Clone, Serialize, Deserialize)]\n#[entity(table = \"products\", primary_key = \"id\", store = \"ferrite_orm_sea::SeaPick\")]\npub struct Product { pub id: i64, pub sku: String, pub name: String }\n\n#[controller(\"\u002Fproducts\")]\npub struct ProductsController { products: Repository\u003CProduct> }\n\n#[impl_controller]\nimpl ProductsController {\n    #[inject]\n    pub fn new(products: Repository\u003CProduct>) -> Self { Self { products } }\n\n    #[get(\"\u002F{id}\")]\n    pub async fn show(&self, Path(id): Path\u003Ci64>) -> Result\u003CJson\u003CProduct>, HttpError> {\n        self.products.find_by_pk(id).await\n            .map_err(HttpError::internal)?\n            .ok_or_else(|| HttpError::not_found(\"product\"))\n            .map(Json)\n    }\n}\n```\n\n## Next steps\n\n- [Authentication (JWT)](\u002Fdocs\u002Ftechniques\u002Fauthentication).\n- [Validation](\u002Fdocs\u002Foverview\u002Fvalidation).",{"frontmatter":9,"meta":10,"nodes":48},{"title":5,"description":6},{"toc":11},{"title":12,"searchDepth":13,"depth":14,"links":15},"On This Page",2,3,[16,19,26,39,42,45],{"id":17,"depth":13,"text":18},"entities","Entities",{"id":20,"depth":13,"text":21,"children":22},"repositories","Repositories",[23],{"id":24,"depth":14,"text":25},"repositories-the-contract","The contract",{"id":27,"depth":13,"text":28,"children":29},"the-adapters","The adapters",[30,33,36],{"id":31,"depth":14,"text":32},"the-adapters-in-memory-default","In-memory (default)",{"id":34,"depth":14,"text":35},"the-adapters-seaorm","SeaORM",{"id":37,"depth":14,"text":38},"the-adapters-coming-soon-sqlx-diesel","Coming soon: SQLx & Diesel",{"id":40,"depth":13,"text":41},"migrations","Migrations",{"id":43,"depth":13,"text":44},"a-repository-heavy-example","A repository-heavy example",{"id":46,"depth":13,"text":47},"next-steps","Next steps",[49,53,71,74,81,259,266,421,488,490,499,713,716,890,893,896,1175,1189,1191,1297,1299,1305,1347,1356,1358,1363,1406,1419,1479,1488,1511,1513,1535,1537,1542,1562,1569,1621,1628,1630,1961,1963],[50,51,5],"h1",{"id":52},"database-orm",[54,55,56,57,61,62,65,66,70],"p",{},"Ferrite's ORM is a thin, focused abstraction: define an ",[58,59,60],"strong",{},"entity",", pick a ",[58,63,64],{},"store"," adapter, inject a ",[67,68,69],"code",{},"Repository\u003CE>",", and get CRUD. It stays deliberately small — no unit-of-work, no implicit change tracking, no relations. Everything is explicit and type-checked.",[72,73,18],"h2",{"id":17},[54,75,76,77,80],{},"Define an entity as a plain struct with ",[67,78,79],{},"serde"," derives:",[82,83,86],"pre",{"language":84,"class":85},"rust","shiki shiki-themes github-light github-dark dark:github-dark",[67,87,89,121,122,121,134,121,136,121,160,121,182,121,196,121,213,121,227,121,240,121,254],{"class":88},"language-rust",[90,91,94,98,102,105,109,112,115,118],"span",{"class":92,"style":93},"line","display: inline",[90,95,97],{"style":96},"color:#D73A49;--shiki-dark:#F97583","use",[90,99,101],{"style":100},"color:#6F42C1;--shiki-dark:#B392F0"," serde",[90,103,104],{"style":96},"::",[90,106,108],{"style":107},"color:#24292E;--shiki-dark:#E1E4E8","{",[90,110,111],{"style":100},"Deserialize",[90,113,114],{"style":107},", ",[90,116,117],{"style":100},"Serialize",[90,119,120],{"style":107},"};","\n",[90,123,124,126,129,131],{"class":92,"style":93},[90,125,97],{"style":96},[90,127,128],{"style":100}," ferrite_framework",[90,130,104],{"style":96},[90,132,133],{"style":107},"entity;",[90,135],{"class":92,"style":93},[90,137,138,141,144,146,149,151,153,155,157],{"class":92,"style":93},[90,139,140],{"style":107},"#[derive(",[90,142,143],{"style":100},"Debug",[90,145,114],{"style":107},[90,147,148],{"style":100},"Clone",[90,150,114],{"style":107},[90,152,117],{"style":100},[90,154,114],{"style":107},[90,156,111],{"style":100},[90,158,159],{"style":107},")]",[90,161,162,165,168,172,175,177,180],{"class":92,"style":93},[90,163,164],{"style":107},"#[entity(table ",[90,166,167],{"style":96},"=",[90,169,171],{"style":170},"color:#032F62;--shiki-dark:#9ECBFF"," \"users\"",[90,173,174],{"style":107},", primary_key ",[90,176,167],{"style":96},[90,178,179],{"style":170}," \"id\"",[90,181,159],{"style":107},[90,183,184,187,190,193],{"class":92,"style":93},[90,185,186],{"style":96},"pub",[90,188,189],{"style":96}," struct",[90,191,192],{"style":100}," User",[90,194,195],{"style":107}," {",[90,197,198,201,204,207,210],{"class":92,"style":93},[90,199,200],{"style":96},"    pub",[90,202,203],{"style":107}," id",[90,205,206],{"style":96},":",[90,208,209],{"style":100}," i64",[90,211,212],{"style":107},",",[90,214,215,217,220,222,225],{"class":92,"style":93},[90,216,200],{"style":96},[90,218,219],{"style":107}," email",[90,221,206],{"style":96},[90,223,224],{"style":100}," String",[90,226,212],{"style":107},[90,228,229,231,234,236,238],{"class":92,"style":93},[90,230,200],{"style":96},[90,232,233],{"style":107}," name",[90,235,206],{"style":96},[90,237,224],{"style":100},[90,239,212],{"style":107},[90,241,242,244,247,249,252],{"class":92,"style":93},[90,243,200],{"style":96},[90,245,246],{"style":107}," age",[90,248,206],{"style":96},[90,250,251],{"style":100}," i32",[90,253,212],{"style":107},[90,255,256],{"class":92,"style":93},[90,257,258],{"style":107},"}",[54,260,261,262,265],{},"The macro generates the ",[67,263,264],{},"Entity"," impl:",[82,267,268],{"language":84,"class":85},[67,269,270,121,306,121,358,121,385,121,417],{"class":88},[90,271,272,274,277,280,282,285,288,291,293,296,298,301,304],{"class":92,"style":93},[90,273,186],{"style":96},[90,275,276],{"style":96}," trait",[90,278,279],{"style":100}," Entity",[90,281,206],{"style":96},[90,283,284],{"style":100}," Clone",[90,286,287],{"style":96}," +",[90,289,290],{"style":100}," Send",[90,292,287],{"style":96},[90,294,295],{"style":100}," Sync",[90,297,287],{"style":96},[90,299,300],{"style":107}," '",[90,302,303],{"style":100},"static",[90,305,195],{"style":107},[90,307,308,311,314,316,318,320,323,325,328,330,332,334,336,338,341,343,345,347,349,351,353,355],{"class":92,"style":93},[90,309,310],{"style":96},"    type",[90,312,313],{"style":100}," PrimaryKey",[90,315,206],{"style":96},[90,317,284],{"style":100},[90,319,287],{"style":96},[90,321,322],{"style":100}," PartialEq",[90,324,287],{"style":96},[90,326,327],{"style":100}," fmt",[90,329,104],{"style":96},[90,331,143],{"style":100},[90,333,287],{"style":96},[90,335,327],{"style":100},[90,337,104],{"style":96},[90,339,340],{"style":100},"Display",[90,342,287],{"style":96},[90,344,290],{"style":100},[90,346,287],{"style":96},[90,348,295],{"style":100},[90,350,287],{"style":96},[90,352,300],{"style":107},[90,354,303],{"style":100},[90,356,357],{"style":107},";",[90,359,360,363,366,369,372,375,378,380,383],{"class":92,"style":93},[90,361,362],{"style":96},"    fn",[90,364,365],{"style":100}," table_name",[90,367,368],{"style":107},"() ",[90,370,371],{"style":96},"->",[90,373,374],{"style":96}," &",[90,376,377],{"style":107},"'",[90,379,303],{"style":100},[90,381,382],{"style":100}," str",[90,384,357],{"style":107},[90,386,387,389,392,395,398,402,405,407,410,412,415],{"class":92,"style":93},[90,388,362],{"style":96},[90,390,391],{"style":100}," primary_key",[90,393,394],{"style":107},"(",[90,396,397],{"style":96},"&",[90,399,401],{"style":400},"color:#005CC5;--shiki-dark:#79B8FF","self",[90,403,404],{"style":107},") ",[90,406,371],{"style":96},[90,408,409],{"style":400}," Self",[90,411,104],{"style":96},[90,413,414],{"style":100},"PrimaryKey",[90,416,357],{"style":107},[90,418,419],{"class":92,"style":93},[90,420,258],{"style":107},[422,423,424,440],"table",{},[425,426,427],"thead",{},[428,429,430,434,437],"tr",{},[431,432,433],"th",{},"Option",[431,435,436],{},"Default",[431,438,439],{},"Notes",[441,442,443,459,474],"tbody",{},[428,444,445,450,453],{},[446,447,448],"td",{},[67,449,422],{},[446,451,452],{},"struct name",[446,454,455,456],{},"e.g. ",[67,457,458],{},"users",[428,460,461,466,471],{},[446,462,463],{},[67,464,465],{},"primary_key",[446,467,468],{},[67,469,470],{},"\"id\"",[446,472,473],{},"the field must exist",[428,475,476,480,485],{},[446,477,478],{},[67,479,64],{},[446,481,482],{},[67,483,484],{},"::ferrite_framework::orm::InMemoryPick",[446,486,487],{},"which picker builds the store",[72,489,21],{"id":20},[54,491,492,495,496,498],{},[67,493,494],{},"#[entity]"," registers ",[67,497,69],{}," as a DI provider automatically:",[82,500,501],{"language":84,"class":85},[67,502,503,121,531,121,575,121,624,121,663,121,709],{"class":88},[90,504,505,508,511,514,516,518,521,524,526,528],{"class":92,"style":93},[90,506,507],{"style":96},"impl",[90,509,510],{"style":107},"\u003C",[90,512,513],{"style":100},"E",[90,515,206],{"style":96},[90,517,279],{"style":100},[90,519,520],{"style":107},"> ",[90,522,523],{"style":100},"Repository",[90,525,510],{"style":107},[90,527,513],{"style":100},[90,529,530],{"style":107},"> {",[90,532,533,535,538,541,544,546,548,550,552,554,557,559,562,564,566,569,572],{"class":92,"style":93},[90,534,200],{"style":96},[90,536,537],{"style":96}," async",[90,539,540],{"style":96}," fn",[90,542,543],{"style":100}," find_all",[90,545,394],{"style":107},[90,547,397],{"style":96},[90,549,401],{"style":400},[90,551,404],{"style":107},[90,553,371],{"style":96},[90,555,556],{"style":100}," Result",[90,558,510],{"style":107},[90,560,561],{"style":100},"Vec",[90,563,510],{"style":107},[90,565,513],{"style":100},[90,567,568],{"style":107},">, ",[90,570,571],{"style":100},"OrmError",[90,573,574],{"style":107},">;",[90,576,577,579,581,583,586,588,590,592,595,597,600,602,604,606,608,610,612,614,616,618,620,622],{"class":92,"style":93},[90,578,200],{"style":96},[90,580,537],{"style":96},[90,582,540],{"style":96},[90,584,585],{"style":100}," find_by_pk",[90,587,394],{"style":107},[90,589,397],{"style":96},[90,591,401],{"style":400},[90,593,594],{"style":107},", pk",[90,596,206],{"style":96},[90,598,599],{"style":100}," E",[90,601,104],{"style":96},[90,603,414],{"style":100},[90,605,404],{"style":107},[90,607,371],{"style":96},[90,609,556],{"style":100},[90,611,510],{"style":107},[90,613,433],{"style":100},[90,615,510],{"style":107},[90,617,513],{"style":100},[90,619,568],{"style":107},[90,621,571],{"style":100},[90,623,574],{"style":107},[90,625,626,628,630,632,635,637,639,641,644,646,648,650,652,654,656,659,661],{"class":92,"style":93},[90,627,200],{"style":96},[90,629,537],{"style":96},[90,631,540],{"style":96},[90,633,634],{"style":100}," save",[90,636,394],{"style":107},[90,638,397],{"style":96},[90,640,401],{"style":400},[90,642,643],{"style":107},", entity",[90,645,206],{"style":96},[90,647,374],{"style":96},[90,649,513],{"style":100},[90,651,404],{"style":107},[90,653,371],{"style":96},[90,655,556],{"style":100},[90,657,658],{"style":107},"\u003C(), ",[90,660,571],{"style":100},[90,662,574],{"style":107},[90,664,665,667,669,671,674,676,678,680,682,684,686,688,690,692,694,696,698,700,703,705,707],{"class":92,"style":93},[90,666,200],{"style":96},[90,668,537],{"style":96},[90,670,540],{"style":96},[90,672,673],{"style":100}," delete",[90,675,394],{"style":107},[90,677,397],{"style":96},[90,679,401],{"style":400},[90,681,594],{"style":107},[90,683,206],{"style":96},[90,685,374],{"style":96},[90,687,513],{"style":100},[90,689,104],{"style":96},[90,691,414],{"style":100},[90,693,404],{"style":107},[90,695,371],{"style":96},[90,697,556],{"style":100},[90,699,510],{"style":107},[90,701,702],{"style":100},"bool",[90,704,114],{"style":107},[90,706,571],{"style":100},[90,708,574],{"style":107},[90,710,711],{"class":92,"style":93},[90,712,258],{"style":107},[54,714,715],{},"Inject it wherever you need it:",[82,717,718],{"language":84,"class":85},[67,719,720,121,725,121,736,121,754,121,758,121,760,121,768,121,773,121,802,121,810,121,815,121,817,121,861,121,882,121,886],{"class":88},[90,721,722],{"class":92,"style":93},[90,723,724],{"style":107},"#[injectable]",[90,726,727,729,731,734],{"class":92,"style":93},[90,728,186],{"style":96},[90,730,189],{"style":96},[90,732,733],{"style":100}," UsersService",[90,735,195],{"style":107},[90,737,738,741,743,746,748,751],{"class":92,"style":93},[90,739,740],{"style":107},"    users",[90,742,206],{"style":96},[90,744,745],{"style":100}," Repository",[90,747,510],{"style":107},[90,749,750],{"style":100},"User",[90,752,753],{"style":107},">,",[90,755,756],{"class":92,"style":93},[90,757,258],{"style":107},[90,759],{"class":92,"style":93},[90,761,762,764,766],{"class":92,"style":93},[90,763,507],{"style":96},[90,765,733],{"style":100},[90,767,195],{"style":107},[90,769,770],{"class":92,"style":93},[90,771,772],{"style":107},"    #[inject]",[90,774,775,777,779,782,785,787,789,791,793,796,798,800],{"class":92,"style":93},[90,776,200],{"style":96},[90,778,540],{"style":96},[90,780,781],{"style":100}," new",[90,783,784],{"style":107},"(users",[90,786,206],{"style":96},[90,788,745],{"style":100},[90,790,510],{"style":107},[90,792,750],{"style":100},[90,794,795],{"style":107},">) ",[90,797,371],{"style":96},[90,799,409],{"style":400},[90,801,195],{"style":107},[90,803,804,807],{"class":92,"style":93},[90,805,806],{"style":400},"        Self",[90,808,809],{"style":107}," { users }",[90,811,812],{"class":92,"style":93},[90,813,814],{"style":107},"    }",[90,816],{"class":92,"style":93},[90,818,819,821,823,825,828,830,832,834,837,839,841,843,845,847,849,851,853,855,857,859],{"class":92,"style":93},[90,820,200],{"style":96},[90,822,537],{"style":96},[90,824,540],{"style":96},[90,826,827],{"style":100}," find",[90,829,394],{"style":107},[90,831,397],{"style":96},[90,833,401],{"style":400},[90,835,836],{"style":107},", id",[90,838,206],{"style":96},[90,840,209],{"style":100},[90,842,404],{"style":107},[90,844,371],{"style":96},[90,846,556],{"style":100},[90,848,510],{"style":107},[90,850,433],{"style":100},[90,852,510],{"style":107},[90,854,750],{"style":100},[90,856,568],{"style":107},[90,858,571],{"style":100},[90,860,530],{"style":107},[90,862,863,866,869,871,873,876,879],{"class":92,"style":93},[90,864,865],{"style":400},"        self",[90,867,868],{"style":96},".",[90,870,458],{"style":107},[90,872,868],{"style":96},[90,874,875],{"style":100},"find_by_pk",[90,877,878],{"style":107},"(id)",[90,880,881],{"style":96},".await",[90,883,884],{"class":92,"style":93},[90,885,814],{"style":107},[90,887,888],{"class":92,"style":93},[90,889,258],{"style":107},[891,892,25],"h3",{"id":24},[54,894,895],{},"The runtime is described by two traits, so adapters are swappable:",[82,897,898],{"language":84,"class":85},[67,899,900,121,905,121,941,121,976,121,1024,121,1058,121,1096,121,1100,121,1102,121,1137,121,1171],{"class":88},[90,901,902],{"class":92,"style":93},[90,903,904],{"style":107},"#[async_trait]",[90,906,907,909,911,914,916,918,920,922,925,927,929,931,933,935,937,939],{"class":92,"style":93},[90,908,186],{"style":96},[90,910,276],{"style":96},[90,912,913],{"style":100}," Store",[90,915,510],{"style":107},[90,917,513],{"style":100},[90,919,206],{"style":96},[90,921,279],{"style":100},[90,923,924],{"style":107},">",[90,926,206],{"style":96},[90,928,290],{"style":100},[90,930,287],{"style":96},[90,932,295],{"style":100},[90,934,287],{"style":96},[90,936,300],{"style":107},[90,938,303],{"style":100},[90,940,195],{"style":107},[90,942,943,946,948,950,952,954,956,958,960,962,964,966,968,970,972,974],{"class":92,"style":93},[90,944,945],{"style":96},"    async",[90,947,540],{"style":96},[90,949,543],{"style":100},[90,951,394],{"style":107},[90,953,397],{"style":96},[90,955,401],{"style":400},[90,957,404],{"style":107},[90,959,371],{"style":96},[90,961,556],{"style":100},[90,963,510],{"style":107},[90,965,561],{"style":100},[90,967,510],{"style":107},[90,969,513],{"style":100},[90,971,568],{"style":107},[90,973,571],{"style":100},[90,975,574],{"style":107},[90,977,978,980,982,984,986,988,990,992,994,996,999,1001,1003,1005,1007,1009,1011,1013,1015,1017,1020],{"class":92,"style":93},[90,979,945],{"style":96},[90,981,540],{"style":96},[90,983,585],{"style":100},[90,985,394],{"style":107},[90,987,397],{"style":96},[90,989,401],{"style":400},[90,991,594],{"style":107},[90,993,206],{"style":96},[90,995,374],{"style":96},[90,997,998],{"style":100},"str",[90,1000,404],{"style":107},[90,1002,371],{"style":96},[90,1004,556],{"style":100},[90,1006,510],{"style":107},[90,1008,433],{"style":100},[90,1010,510],{"style":107},[90,1012,513],{"style":100},[90,1014,568],{"style":107},[90,1016,571],{"style":100},[90,1018,1019],{"style":107},">;  ",[90,1021,1023],{"style":1022},"color:#6A737D;--shiki-dark:#6A737D","\u002F\u002F stringified key (object-safe)",[90,1025,1026,1028,1030,1032,1034,1036,1038,1040,1042,1044,1046,1048,1050,1052,1054,1056],{"class":92,"style":93},[90,1027,945],{"style":96},[90,1029,540],{"style":96},[90,1031,634],{"style":100},[90,1033,394],{"style":107},[90,1035,397],{"style":96},[90,1037,401],{"style":400},[90,1039,643],{"style":107},[90,1041,206],{"style":96},[90,1043,374],{"style":96},[90,1045,513],{"style":100},[90,1047,404],{"style":107},[90,1049,371],{"style":96},[90,1051,556],{"style":100},[90,1053,658],{"style":107},[90,1055,571],{"style":100},[90,1057,574],{"style":107},[90,1059,1060,1062,1064,1066,1068,1070,1072,1074,1076,1078,1080,1082,1084,1086,1088,1090,1092,1094],{"class":92,"style":93},[90,1061,945],{"style":96},[90,1063,540],{"style":96},[90,1065,673],{"style":100},[90,1067,394],{"style":107},[90,1069,397],{"style":96},[90,1071,401],{"style":400},[90,1073,594],{"style":107},[90,1075,206],{"style":96},[90,1077,374],{"style":96},[90,1079,998],{"style":100},[90,1081,404],{"style":107},[90,1083,371],{"style":96},[90,1085,556],{"style":100},[90,1087,510],{"style":107},[90,1089,702],{"style":100},[90,1091,114],{"style":107},[90,1093,571],{"style":100},[90,1095,574],{"style":107},[90,1097,1098],{"class":92,"style":93},[90,1099,258],{"style":107},[90,1101],{"class":92,"style":93},[90,1103,1104,1106,1108,1111,1113,1115,1117,1119,1121,1123,1125,1127,1129,1131,1133,1135],{"class":92,"style":93},[90,1105,186],{"style":96},[90,1107,276],{"style":96},[90,1109,1110],{"style":100}," Pick",[90,1112,510],{"style":107},[90,1114,513],{"style":100},[90,1116,206],{"style":96},[90,1118,279],{"style":100},[90,1120,924],{"style":107},[90,1122,206],{"style":96},[90,1124,290],{"style":100},[90,1126,287],{"style":96},[90,1128,295],{"style":100},[90,1130,287],{"style":96},[90,1132,300],{"style":107},[90,1134,303],{"style":100},[90,1136,195],{"style":107},[90,1138,1139,1141,1144,1146,1148,1150,1152,1154,1157,1159,1162,1164,1166,1168],{"class":92,"style":93},[90,1140,362],{"style":96},[90,1142,1143],{"style":100}," build",[90,1145,394],{"style":107},[90,1147,397],{"style":96},[90,1149,401],{"style":400},[90,1151,404],{"style":107},[90,1153,371],{"style":96},[90,1155,1156],{"style":100}," Arc",[90,1158,510],{"style":107},[90,1160,1161],{"style":96},"dyn",[90,1163,913],{"style":100},[90,1165,510],{"style":107},[90,1167,513],{"style":100},[90,1169,1170],{"style":107},">>;",[90,1172,1173],{"class":92,"style":93},[90,1174,258],{"style":107},[54,1176,1177,1179,1180,114,1183,114,1186,868],{},[67,1178,571],{}," has three shapes: ",[67,1181,1182],{},"NotFound",[67,1184,1185],{},"Key(String)",[67,1187,1188],{},"Backend(String)",[72,1190,28],{"id":27},[422,1192,1193,1206],{},[425,1194,1195],{},[428,1196,1197,1200,1203],{},[431,1198,1199],{},"Adapter",[431,1201,1202],{},"Crate",[431,1204,1205],{},"Status",[441,1207,1208,1229,1255,1278],{},[428,1209,1210,1213,1223],{},[446,1211,1212],{},"In-memory",[446,1214,1215,1218,1219,1222],{},[67,1216,1217],{},"ferrite-orm"," (",[67,1220,1221],{},"InMemoryPick",")",[446,1224,1225,1228],{},[58,1226,1227],{},"Works"," — global provider, zero setup",[428,1230,1231,1234,1242],{},[446,1232,1233],{},"Sea",[446,1235,1236,1218,1239,1222],{},[67,1237,1238],{},"ferrite-orm-sea",[67,1240,1241],{},"SeaPick",[446,1243,1244,1246,1247,1250,1251,1254],{},[58,1245,1227],{}," — full ",[67,1248,1249],{},"Store"," + ",[67,1252,1253],{},"ModelEntity"," bridge, migrations harness",[428,1256,1257,1260,1268],{},[446,1258,1259],{},"SQLx",[446,1261,1262,1218,1265,1222],{},[67,1263,1264],{},"ferrite-orm-sqlx",[67,1266,1267],{},"SqlxPick",[446,1269,1270,1273,1274,1277],{},[58,1271,1272],{},"Stub"," — provider registered, no ",[67,1275,1276],{},"Pick\u003CE>"," impl yet",[428,1279,1280,1283,1291],{},[446,1281,1282],{},"Diesel",[446,1284,1285,1218,1288,1222],{},[67,1286,1287],{},"ferrite-orm-diesel",[67,1289,1290],{},"DieselPick",[446,1292,1293,1273,1295,1277],{},[58,1294,1272],{},[67,1296,1276],{},[891,1298,32],{"id":31},[54,1300,1301,1302,1304],{},"Save an entity with ",[67,1303,64],{}," omitted:",[82,1306,1307],{"language":84,"class":85},[67,1308,1309,121,1313],{"class":88},[90,1310,1311],{"class":92,"style":93},[90,1312,494],{"style":107},[90,1314,1315,1317,1319,1322,1325,1327,1329,1331,1333,1335,1337,1340,1342,1344],{"class":92,"style":93},[90,1316,186],{"style":96},[90,1318,189],{"style":96},[90,1320,1321],{"style":100}," Note",[90,1323,1324],{"style":107}," { ",[90,1326,186],{"style":96},[90,1328,203],{"style":107},[90,1330,206],{"style":96},[90,1332,209],{"style":100},[90,1334,114],{"style":107},[90,1336,186],{"style":96},[90,1338,1339],{"style":107}," body",[90,1341,206],{"style":96},[90,1343,224],{"style":100},[90,1345,1346],{"style":107}," }",[54,1348,1349,1351,1352,1355],{},[67,1350,1221],{}," is a global singleton, so ",[67,1353,1354],{},"Repository\u003CNote>"," resolves without any module import. It's perfect for tests, prototypes, and the scaffolded examples.",[891,1357,35],{"id":34},[54,1359,1360,1361,206],{},"Pick the Sea adapter with an explicit ",[67,1362,64],{},[82,1364,1365],{"language":84,"class":85},[67,1366,1367,121,1391],{"class":88},[90,1368,1369,1371,1373,1375,1377,1379,1381,1384,1386,1389],{"class":92,"style":93},[90,1370,164],{"style":107},[90,1372,167],{"style":96},[90,1374,171],{"style":170},[90,1376,174],{"style":107},[90,1378,167],{"style":96},[90,1380,179],{"style":170},[90,1382,1383],{"style":107},", store ",[90,1385,167],{"style":96},[90,1387,1388],{"style":170}," \"ferrite_orm_sea::SeaPick\"",[90,1390,159],{"style":107},[90,1392,1393,1395,1397,1399,1401,1404],{"class":92,"style":93},[90,1394,186],{"style":96},[90,1396,189],{"style":96},[90,1398,192],{"style":100},[90,1400,1324],{"style":107},[90,1402,1403],{"style":1022},"\u002F* ... *\u002F",[90,1405,1346],{"style":107},[54,1407,1408,1410,1411,1414,1415,1418],{},[67,1409,1241],{}," requires ",[67,1412,1413],{},"E: Entity + ModelEntity + FromQueryResult",". It validates the ",[67,1416,1417],{},"DATABASE_URL"," scheme and feature flags:",[422,1420,1421,1431],{},[425,1422,1423],{},[428,1424,1425,1428],{},[431,1426,1427],{},"Feature",[431,1429,1430],{},"Schemes",[441,1432,1433,1452,1467],{},[428,1434,1435,1440],{},[446,1436,1437],{},[67,1438,1439],{},"sqlite",[446,1441,1442,114,1445,1448,1449,1222],{},[67,1443,1444],{},"sqlite:",[67,1446,1447],{},"sqlite:\u002F\u002F"," (default ",[67,1450,1451],{},"sqlite::memory:",[428,1453,1454,1459],{},[446,1455,1456],{},[67,1457,1458],{},"postgres",[446,1460,1461,114,1464],{},[67,1462,1463],{},"postgres:\u002F\u002F",[67,1465,1466],{},"postgresql:\u002F\u002F",[428,1468,1469,1474],{},[446,1470,1471],{},[67,1472,1473],{},"mysql",[446,1475,1476],{},[67,1477,1478],{},"mysql:\u002F\u002F",[54,1480,1481,1482,1484,1485,206],{},"Configure ",[67,1483,1238],{}," in your ",[67,1486,1487],{},"Cargo.toml",[82,1489,1491],{"language":1490,"class":85},"toml",[67,1492,1494],{"class":1493},"language-toml",[90,1495,1496,1499,1502,1505,1508],{"class":92,"style":93},[90,1497,1498],{"style":107},"ferrite-orm-sea = { version = ",[90,1500,1501],{"style":170},"\"=0.1.0\"",[90,1503,1504],{"style":107},", features = [",[90,1506,1507],{"style":170},"\"postgres\"",[90,1509,1510],{"style":107},"] }",[891,1512,38],{"id":37},[54,1514,1515,1516,1518,1519,1521,1522,1518,1525,1528,1529,1518,1531,1534],{},"The ",[67,1517,1267],{}," \u002F ",[67,1520,1290],{}," providers and ",[67,1523,1524],{},"SqlxStore\u003CE>",[67,1526,1527],{},"DieselStore\u003CE>"," constructors exist, but the ",[67,1530,1276],{},[67,1532,1533],{},"Store\u003CE>"," impls are not wired yet. If you try to use them today you'll get a compiler error — the docs will be updated when the adapters land.",[72,1536,41],{"id":40},[54,1538,1539,1541],{},[67,1540,1238],{}," ships a full migrations harness driven by the CLI:",[82,1543,1545],{"language":1544,"class":85},"bash",[67,1546,1548],{"class":1547},"language-bash",[90,1549,1550,1553,1556,1559],{"class":92,"style":93},[90,1551,1552],{"style":100},"fr",[90,1554,1555],{"style":170}," db",[90,1557,1558],{"style":170}," migrate-create",[90,1560,1561],{"style":170}," add_users_table",[54,1563,1564,1565,1568],{},"Creates ",[67,1566,1567],{},"migrations\u002F\u003Ctimestamp>_add_users_table\u002F{up.sql,down.sql}",". Then:",[82,1570,1571],{"language":1544,"class":85},[67,1572,1573,121,1585,121,1597,121,1609],{"class":1547},[90,1574,1575,1577,1579,1582],{"class":92,"style":93},[90,1576,1552],{"style":100},[90,1578,1555],{"style":170},[90,1580,1581],{"style":170}," migrate",[90,1583,1584],{"style":1022},"    # applies pending migrations (records in __ferrite_migrations)",[90,1586,1587,1589,1591,1594],{"class":92,"style":93},[90,1588,1552],{"style":100},[90,1590,1555],{"style":170},[90,1592,1593],{"style":170}," revert",[90,1595,1596],{"style":1022},"     # rolls back the last applied",[90,1598,1599,1601,1603,1606],{"class":92,"style":93},[90,1600,1552],{"style":100},[90,1602,1555],{"style":170},[90,1604,1605],{"style":170}," seed",[90,1607,1608],{"style":1022},"       # runs seeds\u002F*.sql",[90,1610,1611,1613,1615,1618],{"class":92,"style":93},[90,1612,1552],{"style":100},[90,1614,1555],{"style":170},[90,1616,1617],{"style":170}," status",[90,1619,1620],{"style":1022},"     # applied vs pending report",[54,1622,1623,1624,1627],{},"The harness honors ",[67,1625,1626],{},"FERRITE_DB_ACTION"," and runs via the app binary, so your app's exact connection config drives it.",[72,1629,44],{"id":43},[82,1631,1632],{"language":84,"class":85},[67,1633,1634,121,1654,121,1677,121,1719,121,1721,121,1731,121,1755,121,1757,121,1762,121,1770,121,1774,121,1807,121,1809,121,1819,121,1875,121,1892,121,1912,121,1940,121,1953,121,1957],{"class":88},[90,1635,1636,1638,1640,1642,1644,1646,1648,1650,1652],{"class":92,"style":93},[90,1637,140],{"style":107},[90,1639,143],{"style":100},[90,1641,114],{"style":107},[90,1643,148],{"style":100},[90,1645,114],{"style":107},[90,1647,117],{"style":100},[90,1649,114],{"style":107},[90,1651,111],{"style":100},[90,1653,159],{"style":107},[90,1655,1656,1658,1660,1663,1665,1667,1669,1671,1673,1675],{"class":92,"style":93},[90,1657,164],{"style":107},[90,1659,167],{"style":96},[90,1661,1662],{"style":170}," \"products\"",[90,1664,174],{"style":107},[90,1666,167],{"style":96},[90,1668,179],{"style":170},[90,1670,1383],{"style":107},[90,1672,167],{"style":96},[90,1674,1388],{"style":170},[90,1676,159],{"style":107},[90,1678,1679,1681,1683,1686,1688,1690,1692,1694,1696,1698,1700,1703,1705,1707,1709,1711,1713,1715,1717],{"class":92,"style":93},[90,1680,186],{"style":96},[90,1682,189],{"style":96},[90,1684,1685],{"style":100}," Product",[90,1687,1324],{"style":107},[90,1689,186],{"style":96},[90,1691,203],{"style":107},[90,1693,206],{"style":96},[90,1695,209],{"style":100},[90,1697,114],{"style":107},[90,1699,186],{"style":96},[90,1701,1702],{"style":107}," sku",[90,1704,206],{"style":96},[90,1706,224],{"style":100},[90,1708,114],{"style":107},[90,1710,186],{"style":96},[90,1712,233],{"style":107},[90,1714,206],{"style":96},[90,1716,224],{"style":100},[90,1718,1346],{"style":107},[90,1720],{"class":92,"style":93},[90,1722,1723,1726,1729],{"class":92,"style":93},[90,1724,1725],{"style":107},"#[controller(",[90,1727,1728],{"style":170},"\"\u002Fproducts\"",[90,1730,159],{"style":107},[90,1732,1733,1735,1737,1740,1743,1745,1747,1749,1752],{"class":92,"style":93},[90,1734,186],{"style":96},[90,1736,189],{"style":96},[90,1738,1739],{"style":100}," ProductsController",[90,1741,1742],{"style":107}," { products",[90,1744,206],{"style":96},[90,1746,745],{"style":100},[90,1748,510],{"style":107},[90,1750,1751],{"style":100},"Product",[90,1753,1754],{"style":107},"> }",[90,1756],{"class":92,"style":93},[90,1758,1759],{"class":92,"style":93},[90,1760,1761],{"style":107},"#[impl_controller]",[90,1763,1764,1766,1768],{"class":92,"style":93},[90,1765,507],{"style":96},[90,1767,1739],{"style":100},[90,1769,195],{"style":107},[90,1771,1772],{"class":92,"style":93},[90,1773,772],{"style":107},[90,1775,1776,1778,1780,1782,1785,1787,1789,1791,1793,1795,1797,1799,1801,1804],{"class":92,"style":93},[90,1777,200],{"style":96},[90,1779,540],{"style":96},[90,1781,781],{"style":100},[90,1783,1784],{"style":107},"(products",[90,1786,206],{"style":96},[90,1788,745],{"style":100},[90,1790,510],{"style":107},[90,1792,1751],{"style":100},[90,1794,795],{"style":107},[90,1796,371],{"style":96},[90,1798,409],{"style":400},[90,1800,1324],{"style":107},[90,1802,1803],{"style":400},"Self",[90,1805,1806],{"style":107}," { products } }",[90,1808],{"class":92,"style":93},[90,1810,1811,1814,1817],{"class":92,"style":93},[90,1812,1813],{"style":107},"    #[get(",[90,1815,1816],{"style":170},"\"\u002F{id}\"",[90,1818,159],{"style":107},[90,1820,1821,1823,1825,1827,1830,1832,1834,1836,1838,1841,1843,1845,1848,1850,1853,1855,1857,1859,1861,1864,1866,1868,1870,1873],{"class":92,"style":93},[90,1822,200],{"style":96},[90,1824,537],{"style":96},[90,1826,540],{"style":96},[90,1828,1829],{"style":100}," show",[90,1831,394],{"style":107},[90,1833,397],{"style":96},[90,1835,401],{"style":400},[90,1837,114],{"style":107},[90,1839,1840],{"style":100},"Path",[90,1842,878],{"style":107},[90,1844,206],{"style":96},[90,1846,1847],{"style":100}," Path",[90,1849,510],{"style":107},[90,1851,1852],{"style":100},"i64",[90,1854,795],{"style":107},[90,1856,371],{"style":96},[90,1858,556],{"style":100},[90,1860,510],{"style":107},[90,1862,1863],{"style":100},"Json",[90,1865,510],{"style":107},[90,1867,1751],{"style":100},[90,1869,568],{"style":107},[90,1871,1872],{"style":100},"HttpError",[90,1874,530],{"style":107},[90,1876,1877,1879,1881,1884,1886,1888,1890],{"class":92,"style":93},[90,1878,865],{"style":400},[90,1880,868],{"style":96},[90,1882,1883],{"style":107},"products",[90,1885,868],{"style":96},[90,1887,875],{"style":100},[90,1889,878],{"style":107},[90,1891,881],{"style":96},[90,1893,1894,1897,1900,1902,1904,1906,1909],{"class":92,"style":93},[90,1895,1896],{"style":96},"            .",[90,1898,1899],{"style":100},"map_err",[90,1901,394],{"style":107},[90,1903,1872],{"style":100},[90,1905,104],{"style":96},[90,1907,1908],{"style":107},"internal)",[90,1910,1911],{"style":96},"?",[90,1913,1914,1916,1919,1921,1924,1927,1929,1932,1934,1937],{"class":92,"style":93},[90,1915,1896],{"style":96},[90,1917,1918],{"style":100},"ok_or_else",[90,1920,394],{"style":107},[90,1922,1923],{"style":96},"||",[90,1925,1926],{"style":100}," HttpError",[90,1928,104],{"style":96},[90,1930,1931],{"style":100},"not_found",[90,1933,394],{"style":107},[90,1935,1936],{"style":170},"\"product\"",[90,1938,1939],{"style":107},"))",[90,1941,1942,1944,1947,1949,1951],{"class":92,"style":93},[90,1943,1896],{"style":96},[90,1945,1946],{"style":100},"map",[90,1948,394],{"style":107},[90,1950,1863],{"style":100},[90,1952,1222],{"style":107},[90,1954,1955],{"class":92,"style":93},[90,1956,814],{"style":107},[90,1958,1959],{"class":92,"style":93},[90,1960,258],{"style":107},[72,1962,47],{"id":46},[1964,1965,1966,1974],"ul",{},[1967,1968,1969,868],"li",{},[1970,1971,1973],"a",{"href":1972},"\u002Fdocs\u002Ftechniques\u002Fauthentication","Authentication (JWT)",[1967,1975,1976,868],{},[1970,1977,1979],{"href":1978},"\u002Fdocs\u002Foverview\u002Fvalidation","Validation",{"title":12,"searchDepth":13,"depth":14,"links":1981},[1982,1983,1986,1991,1992,1993],{"id":17,"depth":13,"text":18},{"id":20,"depth":13,"text":21,"children":1984},[1985],{"id":24,"depth":14,"text":25},{"id":27,"depth":13,"text":28,"children":1987},[1988,1989,1990],{"id":31,"depth":14,"text":32},{"id":34,"depth":14,"text":35},{"id":37,"depth":14,"text":38},{"id":40,"depth":13,"text":41},{"id":43,"depth":13,"text":44},{"id":46,"depth":13,"text":47},"https:\u002F\u002Fgithub.com\u002Fj4flmao\u002Fferrite_rs\u002Fedit\u002Fmain\u002Fdocs\u002Fcontent\u002Ftechniques\u002Fdatabase.md",{"title":1996,"slug":1997},"Health checks","fundamentals\u002Fhealth-checks",{"title":1973,"slug":1999},"techniques\u002Fauthentication",1789565439198]