[{"data":1,"prerenderedAt":693},["ShallowReactive",2],{"navigation_docs_en":3,"-en-tauri-sqlite-orm-core-concepts-the-orm-instance":237,"-en-tauri-sqlite-orm-core-concepts-the-orm-instance-surround":688},[4,15,69,122],{"title":5,"icon":6,"path":7,"stem":8,"children":9,"page":14},"Getting Started with Docs","i-lucide-home","/en/getting-started","en/1.getting-started",[10],{"title":11,"path":12,"stem":13,"icon":6},"Introduction","/en/getting-started/introduction","en/1.getting-started/1.introduction",false,{"title":16,"path":17,"stem":18,"children":19,"page":14},"owo-ui Components","/en/owo-ui-components","en/2.owo-ui-components",[20,23],{"title":11,"path":21,"stem":22,"icon":6},"/en/owo-ui-components/introduction","en/2.owo-ui-components/2.introduction",{"title":24,"icon":25,"path":26,"stem":27,"children":28,"page":14},"Components","i-lucide-layout","/en/owo-ui-components/components","en/2.owo-ui-components/3.components",[29,33,37,41,45,49,53,57,61,65],{"title":30,"path":31,"stem":32},"Button","/en/owo-ui-components/components/button","en/2.owo-ui-components/3.components/button",{"title":34,"path":35,"stem":36},"Checkbox","/en/owo-ui-components/components/checkbox","en/2.owo-ui-components/3.components/checkbox",{"title":38,"path":39,"stem":40},"Collapsible Container","/en/owo-ui-components/components/collapsible-container","en/2.owo-ui-components/3.components/collapsible-container",{"title":42,"path":43,"stem":44},"Dropdown","/en/owo-ui-components/components/dropdown","en/2.owo-ui-components/3.components/dropdown",{"title":46,"path":47,"stem":48},"Flow Layout","/en/owo-ui-components/components/flow-layout","en/2.owo-ui-components/3.components/flow-layout",{"title":50,"path":51,"stem":52},"Grid Layout","/en/owo-ui-components/components/grid-layout","en/2.owo-ui-components/3.components/grid-layout",{"title":54,"path":55,"stem":56},"Label","/en/owo-ui-components/components/label","en/2.owo-ui-components/3.components/label",{"title":58,"path":59,"stem":60},"Scroll Container","/en/owo-ui-components/components/scroll-container","en/2.owo-ui-components/3.components/scroll-container",{"title":62,"path":63,"stem":64},"Slider","/en/owo-ui-components/components/slider","en/2.owo-ui-components/3.components/slider",{"title":66,"path":67,"stem":68},"Templates","/en/owo-ui-components/components/templates","en/2.owo-ui-components/3.components/templates",{"title":70,"path":71,"stem":72,"children":73,"page":14},"Nexus","/en/nexus","en/3.nexus",[74,77,82],{"title":11,"path":75,"stem":76,"icon":6},"/en/nexus/introduction","en/3.nexus/2.introduction",{"title":78,"path":79,"stem":80,"icon":81},"Deployment","/en/nexus/deployment","en/3.nexus/3.deployment","i-lucide-rocket",{"title":83,"path":84,"stem":85,"children":86,"page":14},"Endpoints","/en/nexus/endpoints","en/3.nexus/endpoints",[87,91,95,99,102,106,110,114,118],{"title":88,"path":89,"stem":90},"Authentication","/en/nexus/endpoints/authentication","en/3.nexus/endpoints/1.authentication",{"title":92,"path":93,"stem":94},"Rate Limiting","/en/nexus/endpoints/rate-limiting","en/3.nexus/endpoints/2.rate-limiting",{"title":96,"path":97,"stem":98},"Error Handling","/en/nexus/endpoints/error-handling","en/3.nexus/endpoints/3.error-handling",{"title":83,"path":100,"stem":101},"/en/nexus/endpoints/_dir","en/3.nexus/endpoints/_dir",{"title":103,"path":104,"stem":105},"Album","/en/nexus/endpoints/albums","en/3.nexus/endpoints/albums",{"title":107,"path":108,"stem":109},"Blog","/en/nexus/endpoints/blog","en/3.nexus/endpoints/blog",{"title":111,"path":112,"stem":113},"Comments","/en/nexus/endpoints/comments","en/3.nexus/endpoints/comments",{"title":115,"path":116,"stem":117},"File Management","/en/nexus/endpoints/file-management","en/3.nexus/endpoints/file-management",{"title":119,"path":120,"stem":121},"Photo Management","/en/nexus/endpoints/photos","en/3.nexus/endpoints/photos",{"title":123,"icon":124,"path":125,"stem":126,"children":127,"page":14},"Tauri SQLite ORM","i-lucide-database","/en/tauri-sqlite-orm","en/4.tauri-sqlite-orm",[128,132,137,141,162,187,232],{"title":11,"path":129,"stem":130,"icon":131},"/en/tauri-sqlite-orm/introduction","en/4.tauri-sqlite-orm/1.introduction","i-lucide-book-open",{"title":133,"path":134,"stem":135,"icon":136},"Installation & Setup","/en/tauri-sqlite-orm/installation-and-setup","en/4.tauri-sqlite-orm/2.installation-and-setup","i-lucide-download",{"title":138,"path":139,"stem":140,"icon":81},"Your First Schema & Query","/en/tauri-sqlite-orm/your-first-schema-and-query","en/4.tauri-sqlite-orm/3.your-first-schema-and-query",{"title":142,"path":143,"stem":144,"children":145,"page":14},"Core Concepts","/en/tauri-sqlite-orm/core-concepts","en/4.tauri-sqlite-orm/4.core-concepts",[146,150,154,158],{"title":147,"path":148,"stem":149},"Defining Schemas","/en/tauri-sqlite-orm/core-concepts/defining-schemas","en/4.tauri-sqlite-orm/4.core-concepts/1.defining-schemas",{"title":151,"path":152,"stem":153},"Column Types & Modifiers","/en/tauri-sqlite-orm/core-concepts/column-types-and-modifiers","en/4.tauri-sqlite-orm/4.core-concepts/2.column-types-and-modifiers",{"title":155,"path":156,"stem":157},"The ORM Instance","/en/tauri-sqlite-orm/core-concepts/the-orm-instance","en/4.tauri-sqlite-orm/4.core-concepts/3.the-orm-instance",{"title":159,"path":160,"stem":161},"Migrations","/en/tauri-sqlite-orm/core-concepts/migrations","en/4.tauri-sqlite-orm/4.core-concepts/4.migrations",{"title":163,"path":164,"stem":165,"children":166,"page":14},"Querying Data","/en/tauri-sqlite-orm/querying-data","en/4.tauri-sqlite-orm/5.querying-data",[167,171,175,179,183],{"title":168,"path":169,"stem":170},"Select","/en/tauri-sqlite-orm/querying-data/selecting-data","en/4.tauri-sqlite-orm/5.querying-data/1.selecting-data",{"title":172,"path":173,"stem":174},"Insert","/en/tauri-sqlite-orm/querying-data/inserting-data","en/4.tauri-sqlite-orm/5.querying-data/2.inserting-data",{"title":176,"path":177,"stem":178},"Update","/en/tauri-sqlite-orm/querying-data/updating-data","en/4.tauri-sqlite-orm/5.querying-data/3.updating-data",{"title":180,"path":181,"stem":182},"Delete","/en/tauri-sqlite-orm/querying-data/deleting-data","en/4.tauri-sqlite-orm/5.querying-data/4.deleting-data",{"title":184,"path":185,"stem":186},"Conditions & Operators","/en/tauri-sqlite-orm/querying-data/conditions-and-operators","en/4.tauri-sqlite-orm/5.querying-data/5.conditions-and-operators",{"title":188,"path":189,"stem":190,"children":191,"page":14},"Advanced Topics","/en/tauri-sqlite-orm/advanced-topics","en/4.tauri-sqlite-orm/6.advanced-topics",[192,196,200,204,208,212,216,220,224,228],{"title":193,"path":194,"stem":195},"Relations","/en/tauri-sqlite-orm/advanced-topics/working-with-relations","en/4.tauri-sqlite-orm/6.advanced-topics/1.working-with-relations",{"title":197,"path":198,"stem":199},"Error Handling & Safety","/en/tauri-sqlite-orm/advanced-topics/error-handling-and-safety","en/4.tauri-sqlite-orm/6.advanced-topics/10.error-handling-and-safety",{"title":201,"path":202,"stem":203},"Joins","/en/tauri-sqlite-orm/advanced-topics/joins","en/4.tauri-sqlite-orm/6.advanced-topics/2.joins",{"title":205,"path":206,"stem":207},"Transactions","/en/tauri-sqlite-orm/advanced-topics/transactions","en/4.tauri-sqlite-orm/6.advanced-topics/3.transactions",{"title":209,"path":210,"stem":211},"Common Table Expressions","/en/tauri-sqlite-orm/advanced-topics/common-table-expressions","en/4.tauri-sqlite-orm/6.advanced-topics/4.common-table-expressions",{"title":213,"path":214,"stem":215},"Raw SQL","/en/tauri-sqlite-orm/advanced-topics/raw-sql","en/4.tauri-sqlite-orm/6.advanced-topics/5.raw-sql",{"title":217,"path":218,"stem":219},"Type Safety & Inference","/en/tauri-sqlite-orm/advanced-topics/type-safety-and-inference","en/4.tauri-sqlite-orm/6.advanced-topics/6.type-safety-and-inference",{"title":221,"path":222,"stem":223},"Schema Management","/en/tauri-sqlite-orm/advanced-topics/manual-schema-management","en/4.tauri-sqlite-orm/6.advanced-topics/7.manual-schema-management",{"title":225,"path":226,"stem":227},"Query Debugging","/en/tauri-sqlite-orm/advanced-topics/query-debugging","en/4.tauri-sqlite-orm/6.advanced-topics/8.query-debugging",{"title":229,"path":230,"stem":231},"Subqueries & Aggregates","/en/tauri-sqlite-orm/advanced-topics/subqueries-and-aggregates","en/4.tauri-sqlite-orm/6.advanced-topics/9.subqueries-and-aggregates",{"title":233,"path":234,"stem":235,"icon":236},"API Reference","/en/tauri-sqlite-orm/api-reference","en/4.tauri-sqlite-orm/7.api-reference","i-lucide-book",{"id":238,"title":155,"body":239,"description":682,"extension":683,"links":684,"meta":685,"navigation":338,"path":156,"seo":686,"stem":157,"__hash__":687},"docs_en/en/4.tauri-sqlite-orm/4.core-concepts/3.the-orm-instance.md",{"type":240,"value":241,"toc":673},"minimark",[242,255,260,267,463,468,475,502,508,512,517,521,524,622,626,629,669],[243,244,245,246,250,251,254],"p",{},"The ",[247,248,249],"code",{},"TauriORM"," class is the heart of the library. It's the central entry point for all database interactions, schema management, and transactions. We typically create a single instance of it and export it for use throughout the application, often named ",[247,252,253],{},"db",".",[256,257,259],"h2",{"id":258},"initialization","Initialization",[243,261,262,263,266],{},"You initialize the ORM by passing an active ",[247,264,265],{},"@tauri-apps/plugin-sql"," database connection and your schema definitions to its constructor.",[268,269,275],"pre",{"className":270,"code":271,"filename":272,"language":273,"meta":274,"style":274},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import Database from '@tauri-apps/plugin-sql'\nimport { TauriORM, asTauriDatabase } from '@type32/tauri-sqlite-orm'\n\n// Import all exported tables and relations from your schema file\nimport * as schema from './schema'\n\nconst dbInstance = await Database.load('sqlite:main.db')\n\n// Pass both the connection and the schema object.\n// Use asTauriDatabase() if TypeScript reports type incompatibility.\nexport const db = new TauriORM(asTauriDatabase(dbInstance), schema)\n","src/lib/db/index.ts","ts","",[247,276,277,303,333,340,347,370,375,414,419,425,431],{"__ignoreMap":274},[278,279,282,286,290,293,297,300],"span",{"class":280,"line":281},"line",1,[278,283,285],{"class":284},"s7zQu","import",[278,287,289],{"class":288},"sTEyZ"," Database ",[278,291,292],{"class":284},"from",[278,294,296],{"class":295},"sMK4o"," '",[278,298,265],{"class":299},"sfazB",[278,301,302],{"class":295},"'\n",[278,304,306,308,311,314,317,320,323,326,328,331],{"class":280,"line":305},2,[278,307,285],{"class":284},[278,309,310],{"class":295}," {",[278,312,313],{"class":288}," TauriORM",[278,315,316],{"class":295},",",[278,318,319],{"class":288}," asTauriDatabase",[278,321,322],{"class":295}," }",[278,324,325],{"class":284}," from",[278,327,296],{"class":295},[278,329,330],{"class":299},"@type32/tauri-sqlite-orm",[278,332,302],{"class":295},[278,334,336],{"class":280,"line":335},3,[278,337,339],{"emptyLinePlaceholder":338},true,"\n",[278,341,343],{"class":280,"line":342},4,[278,344,346],{"class":345},"sHwdD","// Import all exported tables and relations from your schema file\n",[278,348,350,352,355,358,361,363,365,368],{"class":280,"line":349},5,[278,351,285],{"class":284},[278,353,354],{"class":295}," *",[278,356,357],{"class":284}," as",[278,359,360],{"class":288}," schema ",[278,362,292],{"class":284},[278,364,296],{"class":295},[278,366,367],{"class":299},"./schema",[278,369,302],{"class":295},[278,371,373],{"class":280,"line":372},6,[278,374,339],{"emptyLinePlaceholder":338},[278,376,378,382,385,388,391,394,396,400,403,406,409,411],{"class":280,"line":377},7,[278,379,381],{"class":380},"spNyl","const",[278,383,384],{"class":288}," dbInstance ",[278,386,387],{"class":295},"=",[278,389,390],{"class":284}," await",[278,392,393],{"class":288}," Database",[278,395,254],{"class":295},[278,397,399],{"class":398},"s2Zo4","load",[278,401,402],{"class":288},"(",[278,404,405],{"class":295},"'",[278,407,408],{"class":299},"sqlite:main.db",[278,410,405],{"class":295},[278,412,413],{"class":288},")\n",[278,415,417],{"class":280,"line":416},8,[278,418,339],{"emptyLinePlaceholder":338},[278,420,422],{"class":280,"line":421},9,[278,423,424],{"class":345},"// Pass both the connection and the schema object.\n",[278,426,428],{"class":280,"line":427},10,[278,429,430],{"class":345},"// Use asTauriDatabase() if TypeScript reports type incompatibility.\n",[278,432,434,437,440,443,445,448,450,452,455,458,460],{"class":280,"line":433},11,[278,435,436],{"class":284},"export",[278,438,439],{"class":380}," const",[278,441,442],{"class":288}," db ",[278,444,387],{"class":295},[278,446,447],{"class":295}," new",[278,449,313],{"class":398},[278,451,402],{"class":288},[278,453,454],{"class":398},"asTauriDatabase",[278,456,457],{"class":288},"(dbInstance)",[278,459,316],{"class":295},[278,461,462],{"class":288}," schema)\n",[464,465,467],"h3",{"id":466},"why-pass-the-schema","Why Pass the Schema?",[243,469,470,471,474],{},"Providing the ",[247,472,473],{},"schema"," object to the constructor is crucial. It enables several key features:",[476,477,478,486,496],"ol",{},[479,480,481,485],"li",{},[482,483,484],"strong",{},"Automatic Migrations:"," The ORM can inspect your schema to determine if the database is out of sync.",[479,487,488,491,492,495],{},[482,489,490],{},"Relation Queries:"," It allows the ORM to understand the relationships you've defined, making ",[247,493,494],{},".include()"," queries possible.",[479,497,498,501],{},[482,499,500],{},"Type Safety:"," It enhances the ORM's ability to provide strong, inferred types for your query results.",[243,503,504,505,507],{},"While you can technically omit the ",[247,506,473],{}," argument, doing so will disable these features, and you will receive warnings in the console.",[256,509,511],{"id":510},"core-methods","Core Methods",[243,513,245,514,516],{},[247,515,253],{}," instance provides a set of methods for interacting with your database. Here is a high-level overview. Each method is covered in detail in its own documentation section.",[464,518,520],{"id":519},"query-builders","Query Builders",[243,522,523],{},"These methods return a chainable query builder instance.",[525,526,527,547,565,581,597,610],"ul",{},[479,528,529,532,533,536,537],{},[247,530,531],{},"db.select(table, columns?)",": Initiates a ",[247,534,535],{},"SELECT"," query.\n",[525,538,539],{},[479,540,541,542],{},"See ",[543,544,546],"a",{"href":545},"/5.querying-data/1.selecting-data","Selecting Data",[479,548,549,552,553,556,557],{},[247,550,551],{},"db.insert(table)",": Initiates an ",[247,554,555],{},"INSERT"," statement.\n",[525,558,559],{},[479,560,541,561],{},[543,562,564],{"href":563},"/5.querying-data/2.inserting-data","Inserting Data",[479,566,567,552,570,556,573],{},[247,568,569],{},"db.update(table)",[247,571,572],{},"UPDATE",[525,574,575],{},[479,576,541,577],{},[543,578,580],{"href":579},"/5.querying-data/3.updating-data","Updating Data",[479,582,583,532,586,556,589],{},[247,584,585],{},"db.delete(table)",[247,587,588],{},"DELETE",[525,590,591],{},[479,592,541,593],{},[543,594,596],{"href":595},"/5.querying-data/4.deleting-data","Deleting Data",[479,598,599,602,603],{},[247,600,601],{},"db.$with(alias).as(query)",": Starts a Common Table Expression (CTE).\n",[525,604,605],{},[479,606,541,607],{},[543,608,209],{"href":609},"/6.advanced-topics/4.common-table-expressions",[479,611,612,615,616],{},[247,613,614],{},"db.upsert(table, data, conflictTarget)",": Insert or update on conflict (shorthand for upsert).\n",[525,617,618],{},[479,619,541,620],{},[543,621,564],{"href":563},[464,623,625],{"id":624},"other-utilities","Other Utilities",[243,627,628],{},"These methods handle transactions and schema management.",[525,630,631,644,657],{},[479,632,633,636,637],{},[247,634,635],{},"db.transaction(callback)",": Executes a series of operations within a transaction.\n",[525,638,639],{},[479,640,541,641],{},[543,642,205],{"href":643},"/6.advanced-topics/3.transactions",[479,645,646,649,650],{},[247,647,648],{},"db.migrateIfDirty()",": Checks for schema changes and applies them if necessary.\n",[525,651,652],{},[479,653,541,654],{},[543,655,159],{"href":656},"/4.core-concepts/4.migrations",[479,658,659,662,663],{},[247,660,661],{},"db.migrate(options?)",": Manually run migrations with optional destructive actions.\n",[525,664,665],{},[479,666,541,667],{},[543,668,159],{"href":656},[670,671,672],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":274,"searchDepth":305,"depth":305,"links":674},[675,678],{"id":258,"depth":305,"text":259,"children":676},[677],{"id":466,"depth":335,"text":467},{"id":510,"depth":305,"text":511,"children":679},[680,681],{"id":519,"depth":335,"text":520},{"id":624,"depth":335,"text":625},"The core of the library.","md",null,{},{"title":155,"description":682},"DtxPaGWCd9P67NHeg0Ag_BZmDL2bPtZAvbeIxm7ZoP0",[689,691],{"title":151,"path":152,"stem":153,"description":690,"children":-1},"All available column helpers and the chainable modifiers used to configure them.",{"title":159,"path":160,"stem":161,"description":692,"children":-1},"Migrations are the process of keeping your database schema synchronized with your application's schema definitions in code. This ORM provides a powerful migration system that can handle both simple and complex schema changes.",1773317302104]