[{"data":1,"prerenderedAt":1562},["ShallowReactive",2],{"navigation_docs_en":3,"-en-tauri-sqlite-orm-querying-data-inserting-data":237,"-en-tauri-sqlite-orm-querying-data-inserting-data-surround":1557},[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":172,"body":239,"description":1551,"extension":1552,"links":1553,"meta":1554,"navigation":344,"path":173,"seo":1555,"stem":174,"__hash__":1556},"docs_en/en/4.tauri-sqlite-orm/5.querying-data/2.inserting-data.md",{"type":240,"value":241,"toc":1533},"minimark",[242,255,260,271,508,525,529,534,637,641,658,665,671,786,792,795,941,947,950,1061,1065,1155,1159,1174,1180,1186,1266,1272,1279,1434,1438,1445,1529],[243,244,245,246,250,251,254],"p",{},"The ",[247,248,249],"code",{},"db.insert()"," method is used to add new rows to a table. It returns a query builder for constructing the ",[247,252,253],{},"INSERT"," statement.",[256,257,259],"h2",{"id":258},"inserting-a-single-row","Inserting a Single Row",[243,261,262,263,266,267,270],{},"To insert a single record, use the ",[247,264,265],{},".values()"," method with a single object. After building the query, call ",[247,268,269],{},".execute()"," to run it.",[272,273,278],"pre",{"className":274,"code":275,"language":276,"meta":277,"style":277},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { db } from '$lib/db';\nimport { users } from '$lib/db/schema';\n\n// Type inference ensures you provide the correct properties.\n// Optional columns (nullable or with defaults) can be omitted.\nconst newUser: InferInsertModel\u003Ctypeof users> = {\n  fullName: 'John Smith',\n  email: 'john.smith@example.com',\n};\n\nconst result = await db.insert(users).values(newUser).execute();\n\nconsole.log(result);\n// [{ rowsAffected: 1, lastInsertId: ... }]\n","ts","",[247,279,280,316,339,346,353,359,390,409,426,432,437,481,486,502],{"__ignoreMap":277},[281,282,285,289,293,297,300,303,306,310,313],"span",{"class":283,"line":284},"line",1,[281,286,288],{"class":287},"s7zQu","import",[281,290,292],{"class":291},"sMK4o"," {",[281,294,296],{"class":295},"sTEyZ"," db",[281,298,299],{"class":291}," }",[281,301,302],{"class":287}," from",[281,304,305],{"class":291}," '",[281,307,309],{"class":308},"sfazB","$lib/db",[281,311,312],{"class":291},"'",[281,314,315],{"class":291},";\n",[281,317,319,321,323,326,328,330,332,335,337],{"class":283,"line":318},2,[281,320,288],{"class":287},[281,322,292],{"class":291},[281,324,325],{"class":295}," users",[281,327,299],{"class":291},[281,329,302],{"class":287},[281,331,305],{"class":291},[281,333,334],{"class":308},"$lib/db/schema",[281,336,312],{"class":291},[281,338,315],{"class":291},[281,340,342],{"class":283,"line":341},3,[281,343,345],{"emptyLinePlaceholder":344},true,"\n",[281,347,349],{"class":283,"line":348},4,[281,350,352],{"class":351},"sHwdD","// Type inference ensures you provide the correct properties.\n",[281,354,356],{"class":283,"line":355},5,[281,357,358],{"class":351},"// Optional columns (nullable or with defaults) can be omitted.\n",[281,360,362,366,369,372,376,379,381,384,387],{"class":283,"line":361},6,[281,363,365],{"class":364},"spNyl","const",[281,367,368],{"class":295}," newUser",[281,370,371],{"class":291},":",[281,373,375],{"class":374},"sBMFI"," InferInsertModel",[281,377,378],{"class":291},"\u003Ctypeof",[281,380,325],{"class":295},[281,382,383],{"class":291},">",[281,385,386],{"class":291}," =",[281,388,389],{"class":291}," {\n",[281,391,393,397,399,401,404,406],{"class":283,"line":392},7,[281,394,396],{"class":395},"swJcz","  fullName",[281,398,371],{"class":291},[281,400,305],{"class":291},[281,402,403],{"class":308},"John Smith",[281,405,312],{"class":291},[281,407,408],{"class":291},",\n",[281,410,412,415,417,419,422,424],{"class":283,"line":411},8,[281,413,414],{"class":395},"  email",[281,416,371],{"class":291},[281,418,305],{"class":291},[281,420,421],{"class":308},"john.smith@example.com",[281,423,312],{"class":291},[281,425,408],{"class":291},[281,427,429],{"class":283,"line":428},9,[281,430,431],{"class":291},"};\n",[281,433,435],{"class":283,"line":434},10,[281,436,345],{"emptyLinePlaceholder":344},[281,438,440,442,445,448,451,453,456,460,463,465,468,471,473,476,479],{"class":283,"line":439},11,[281,441,365],{"class":364},[281,443,444],{"class":295}," result ",[281,446,447],{"class":291},"=",[281,449,450],{"class":287}," await",[281,452,296],{"class":295},[281,454,455],{"class":291},".",[281,457,459],{"class":458},"s2Zo4","insert",[281,461,462],{"class":295},"(users)",[281,464,455],{"class":291},[281,466,467],{"class":458},"values",[281,469,470],{"class":295},"(newUser)",[281,472,455],{"class":291},[281,474,475],{"class":458},"execute",[281,477,478],{"class":295},"()",[281,480,315],{"class":291},[281,482,484],{"class":283,"line":483},12,[281,485,345],{"emptyLinePlaceholder":344},[281,487,489,492,494,497,500],{"class":283,"line":488},13,[281,490,491],{"class":295},"console",[281,493,455],{"class":291},[281,495,496],{"class":458},"log",[281,498,499],{"class":295},"(result)",[281,501,315],{"class":291},[281,503,505],{"class":283,"line":504},14,[281,506,507],{"class":351},"// [{ rowsAffected: 1, lastInsertId: ... }]\n",[509,510,513,519,520,524],"callout",{"color":511,"icon":512},"primary","i-lucide-info",[514,515,516],"strong",{},[247,517,518],{},"InferInsertModel",": This is a helper type that correctly represents the shape of an object for insertion, marking columns with default values or that are nullable as optional. See ",[521,522,217],"a",{"href":523},"/6.advanced-topics/6.type-safety-and-inference"," for more.",[256,526,528],{"id":527},"inserting-multiple-rows","Inserting Multiple Rows",[243,530,531,532,455],{},"You can also insert multiple rows in a single, more efficient query by passing an array to ",[247,533,265],{},[272,535,537],{"className":274,"code":536,"language":276,"meta":277,"style":277},"await db.insert(users).values([\n  { fullName: 'Alice', email: 'alice@example.com' },\n  { fullName: 'Bob', email: 'bob@example.com' },\n]).execute();\n",[247,538,539,559,594,624],{"__ignoreMap":277},[281,540,541,544,546,548,550,552,554,556],{"class":283,"line":284},[281,542,543],{"class":287},"await",[281,545,296],{"class":295},[281,547,455],{"class":291},[281,549,459],{"class":458},[281,551,462],{"class":295},[281,553,455],{"class":291},[281,555,467],{"class":458},[281,557,558],{"class":295},"([\n",[281,560,561,564,567,569,571,574,576,579,582,584,586,589,591],{"class":283,"line":318},[281,562,563],{"class":291},"  {",[281,565,566],{"class":395}," fullName",[281,568,371],{"class":291},[281,570,305],{"class":291},[281,572,573],{"class":308},"Alice",[281,575,312],{"class":291},[281,577,578],{"class":291},",",[281,580,581],{"class":395}," email",[281,583,371],{"class":291},[281,585,305],{"class":291},[281,587,588],{"class":308},"alice@example.com",[281,590,312],{"class":291},[281,592,593],{"class":291}," },\n",[281,595,596,598,600,602,604,607,609,611,613,615,617,620,622],{"class":283,"line":341},[281,597,563],{"class":291},[281,599,566],{"class":395},[281,601,371],{"class":291},[281,603,305],{"class":291},[281,605,606],{"class":308},"Bob",[281,608,312],{"class":291},[281,610,578],{"class":291},[281,612,581],{"class":395},[281,614,371],{"class":291},[281,616,305],{"class":291},[281,618,619],{"class":308},"bob@example.com",[281,621,312],{"class":291},[281,623,593],{"class":291},[281,625,626,629,631,633,635],{"class":283,"line":348},[281,627,628],{"class":295},"])",[281,630,455],{"class":291},[281,632,475],{"class":458},[281,634,478],{"class":295},[281,636,315],{"class":291},[256,638,640],{"id":639},"returning-inserted-data","Returning Inserted Data",[243,642,643,644,646,647,650,651,654,655,455],{},"By default, an ",[247,645,253],{}," statement returns the number of affected rows and the last inserted ID. If you need the actual data from the newly created rows, you can use ",[247,648,649],{},".returning()",", ",[247,652,653],{},".returningAll()",", or ",[247,656,657],{},".returningFirst()",[659,660,662,664],"h3",{"id":661},"returningfirst-most-common-use-case",[247,663,657],{}," - Most Common Use Case",[243,666,667,668,670],{},"When inserting a single row, use ",[247,669,657],{}," to get the inserted record directly without array destructuring:",[272,672,674],{"className":274,"code":673,"language":276,"meta":277,"style":277},"// ✅ Clean and ergonomic\nconst insertedUser = await db.insert(users)\n  .values({ fullName: 'Carol', email: 'carol@example.com' })\n  .returningFirst();\n\nconsole.log(insertedUser?.id); // The ID generated by the database\n// Type: InferSelectModel\u003Ctypeof users> | undefined\n",[247,675,676,681,701,743,754,758,781],{"__ignoreMap":277},[281,677,678],{"class":283,"line":284},[281,679,680],{"class":351},"// ✅ Clean and ergonomic\n",[281,682,683,685,688,690,692,694,696,698],{"class":283,"line":318},[281,684,365],{"class":364},[281,686,687],{"class":295}," insertedUser ",[281,689,447],{"class":291},[281,691,450],{"class":287},[281,693,296],{"class":295},[281,695,455],{"class":291},[281,697,459],{"class":458},[281,699,700],{"class":295},"(users)\n",[281,702,703,706,708,711,714,716,718,720,723,725,727,729,731,733,736,738,740],{"class":283,"line":341},[281,704,705],{"class":291},"  .",[281,707,467],{"class":458},[281,709,710],{"class":295},"(",[281,712,713],{"class":291},"{",[281,715,566],{"class":395},[281,717,371],{"class":291},[281,719,305],{"class":291},[281,721,722],{"class":308},"Carol",[281,724,312],{"class":291},[281,726,578],{"class":291},[281,728,581],{"class":395},[281,730,371],{"class":291},[281,732,305],{"class":291},[281,734,735],{"class":308},"carol@example.com",[281,737,312],{"class":291},[281,739,299],{"class":291},[281,741,742],{"class":295},")\n",[281,744,745,747,750,752],{"class":283,"line":348},[281,746,705],{"class":291},[281,748,749],{"class":458},"returningFirst",[281,751,478],{"class":295},[281,753,315],{"class":291},[281,755,756],{"class":283,"line":355},[281,757,345],{"emptyLinePlaceholder":344},[281,759,760,762,764,766,769,772,775,778],{"class":283,"line":361},[281,761,491],{"class":295},[281,763,455],{"class":291},[281,765,496],{"class":458},[281,767,768],{"class":295},"(insertedUser",[281,770,771],{"class":291},"?.",[281,773,774],{"class":295},"id)",[281,776,777],{"class":291},";",[281,779,780],{"class":351}," // The ID generated by the database\n",[281,782,783],{"class":283,"line":392},[281,784,785],{"class":351},"// Type: InferSelectModel\u003Ctypeof users> | undefined\n",[659,787,789,791],{"id":788},"returningall-for-multiple-rows",[247,790,653],{}," - For Multiple Rows",[243,793,794],{},"When inserting multiple rows or when you always expect an array:",[272,796,798],{"className":274,"code":797,"language":276,"meta":277,"style":277},"// Return all columns for the newly inserted users\nconst insertedUsers = await db.insert(users)\n  .values([\n    { fullName: 'Carol', email: 'carol@example.com' },\n    { fullName: 'David', email: 'david@example.com' }\n  ])\n  .returningAll();\n\nconsole.log(insertedUsers[0].id);\n// Type: InferSelectModel\u003Ctypeof users>[]\n",[247,799,800,805,824,832,861,892,897,908,912,936],{"__ignoreMap":277},[281,801,802],{"class":283,"line":284},[281,803,804],{"class":351},"// Return all columns for the newly inserted users\n",[281,806,807,809,812,814,816,818,820,822],{"class":283,"line":318},[281,808,365],{"class":364},[281,810,811],{"class":295}," insertedUsers ",[281,813,447],{"class":291},[281,815,450],{"class":287},[281,817,296],{"class":295},[281,819,455],{"class":291},[281,821,459],{"class":458},[281,823,700],{"class":295},[281,825,826,828,830],{"class":283,"line":341},[281,827,705],{"class":291},[281,829,467],{"class":458},[281,831,558],{"class":295},[281,833,834,837,839,841,843,845,847,849,851,853,855,857,859],{"class":283,"line":348},[281,835,836],{"class":291},"    {",[281,838,566],{"class":395},[281,840,371],{"class":291},[281,842,305],{"class":291},[281,844,722],{"class":308},[281,846,312],{"class":291},[281,848,578],{"class":291},[281,850,581],{"class":395},[281,852,371],{"class":291},[281,854,305],{"class":291},[281,856,735],{"class":308},[281,858,312],{"class":291},[281,860,593],{"class":291},[281,862,863,865,867,869,871,874,876,878,880,882,884,887,889],{"class":283,"line":355},[281,864,836],{"class":291},[281,866,566],{"class":395},[281,868,371],{"class":291},[281,870,305],{"class":291},[281,872,873],{"class":308},"David",[281,875,312],{"class":291},[281,877,578],{"class":291},[281,879,581],{"class":395},[281,881,371],{"class":291},[281,883,305],{"class":291},[281,885,886],{"class":308},"david@example.com",[281,888,312],{"class":291},[281,890,891],{"class":291}," }\n",[281,893,894],{"class":283,"line":361},[281,895,896],{"class":295},"  ])\n",[281,898,899,901,904,906],{"class":283,"line":392},[281,900,705],{"class":291},[281,902,903],{"class":458},"returningAll",[281,905,478],{"class":295},[281,907,315],{"class":291},[281,909,910],{"class":283,"line":411},[281,911,345],{"emptyLinePlaceholder":344},[281,913,914,916,918,920,923,927,930,932,934],{"class":283,"line":428},[281,915,491],{"class":295},[281,917,455],{"class":291},[281,919,496],{"class":458},[281,921,922],{"class":295},"(insertedUsers[",[281,924,926],{"class":925},"sbssI","0",[281,928,929],{"class":295},"]",[281,931,455],{"class":291},[281,933,774],{"class":295},[281,935,315],{"class":291},[281,937,938],{"class":283,"line":434},[281,939,940],{"class":351},"// Type: InferSelectModel\u003Ctypeof users>[]\n",[659,942,944,946],{"id":943},"returning-for-specific-columns",[247,945,649],{}," - For Specific Columns",[243,948,949],{},"Return only the columns you need:",[272,951,953],{"className":274,"code":952,"language":276,"meta":277,"style":277},"// Return only specific columns\nconst [insertedId] = await db.insert(users)\n  .values({ fullName: 'David', email: 'david@example.com' })\n  .returning('id');\n\nconsole.log(insertedId); // { id: ... }\n",[247,954,955,960,984,1020,1041,1045],{"__ignoreMap":277},[281,956,957],{"class":283,"line":284},[281,958,959],{"class":351},"// Return only specific columns\n",[281,961,962,964,967,970,972,974,976,978,980,982],{"class":283,"line":318},[281,963,365],{"class":364},[281,965,966],{"class":291}," [",[281,968,969],{"class":295},"insertedId",[281,971,929],{"class":291},[281,973,386],{"class":291},[281,975,450],{"class":287},[281,977,296],{"class":295},[281,979,455],{"class":291},[281,981,459],{"class":458},[281,983,700],{"class":295},[281,985,986,988,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012,1014,1016,1018],{"class":283,"line":341},[281,987,705],{"class":291},[281,989,467],{"class":458},[281,991,710],{"class":295},[281,993,713],{"class":291},[281,995,566],{"class":395},[281,997,371],{"class":291},[281,999,305],{"class":291},[281,1001,873],{"class":308},[281,1003,312],{"class":291},[281,1005,578],{"class":291},[281,1007,581],{"class":395},[281,1009,371],{"class":291},[281,1011,305],{"class":291},[281,1013,886],{"class":308},[281,1015,312],{"class":291},[281,1017,299],{"class":291},[281,1019,742],{"class":295},[281,1021,1022,1024,1027,1029,1031,1034,1036,1039],{"class":283,"line":348},[281,1023,705],{"class":291},[281,1025,1026],{"class":458},"returning",[281,1028,710],{"class":295},[281,1030,312],{"class":291},[281,1032,1033],{"class":308},"id",[281,1035,312],{"class":291},[281,1037,1038],{"class":295},")",[281,1040,315],{"class":291},[281,1042,1043],{"class":283,"line":355},[281,1044,345],{"emptyLinePlaceholder":344},[281,1046,1047,1049,1051,1053,1056,1058],{"class":283,"line":361},[281,1048,491],{"class":295},[281,1050,455],{"class":291},[281,1052,496],{"class":458},[281,1054,1055],{"class":295},"(insertedId)",[281,1057,777],{"class":291},[281,1059,1060],{"class":351}," // { id: ... }\n",[659,1062,1064],{"id":1063},"quick-comparison","Quick Comparison",[272,1066,1068],{"className":274,"code":1067,"language":276,"meta":277,"style":277},"// Old way - need array destructuring\nconst [user] = await db.insert(users).values(data).returningAll();\n\n// New way - cleaner for single inserts\nconst user = await db.insert(users).values(data).returningFirst();\n",[247,1069,1070,1075,1113,1117,1122],{"__ignoreMap":277},[281,1071,1072],{"class":283,"line":284},[281,1073,1074],{"class":351},"// Old way - need array destructuring\n",[281,1076,1077,1079,1081,1084,1086,1088,1090,1092,1094,1096,1098,1100,1102,1105,1107,1109,1111],{"class":283,"line":318},[281,1078,365],{"class":364},[281,1080,966],{"class":291},[281,1082,1083],{"class":295},"user",[281,1085,929],{"class":291},[281,1087,386],{"class":291},[281,1089,450],{"class":287},[281,1091,296],{"class":295},[281,1093,455],{"class":291},[281,1095,459],{"class":458},[281,1097,462],{"class":295},[281,1099,455],{"class":291},[281,1101,467],{"class":458},[281,1103,1104],{"class":295},"(data)",[281,1106,455],{"class":291},[281,1108,903],{"class":458},[281,1110,478],{"class":295},[281,1112,315],{"class":291},[281,1114,1115],{"class":283,"line":341},[281,1116,345],{"emptyLinePlaceholder":344},[281,1118,1119],{"class":283,"line":348},[281,1120,1121],{"class":351},"// New way - cleaner for single inserts\n",[281,1123,1124,1126,1129,1131,1133,1135,1137,1139,1141,1143,1145,1147,1149,1151,1153],{"class":283,"line":355},[281,1125,365],{"class":364},[281,1127,1128],{"class":295}," user ",[281,1130,447],{"class":291},[281,1132,450],{"class":287},[281,1134,296],{"class":295},[281,1136,455],{"class":291},[281,1138,459],{"class":458},[281,1140,462],{"class":295},[281,1142,455],{"class":291},[281,1144,467],{"class":458},[281,1146,1104],{"class":295},[281,1148,455],{"class":291},[281,1150,749],{"class":458},[281,1152,478],{"class":295},[281,1154,315],{"class":291},[256,1156,1158],{"id":1157},"conflict-handling-upsert","Conflict Handling (UPSERT)",[243,1160,1161,1162,1165,1166,1169,1170,1173],{},"SQLite's ",[247,1163,1164],{},"ON CONFLICT"," clause is supported for handling cases where an insert would violate a ",[247,1167,1168],{},"UNIQUE"," or ",[247,1171,1172],{},"PRIMARY KEY"," constraint.",[659,1175,1177],{"id":1176},"onconflictdonothing",[247,1178,1179],{},".onConflictDoNothing()",[243,1181,1182,1183,1185],{},"If a conflict occurs (e.g., trying to insert a user with an email that already exists), this method will cause the ",[247,1184,253],{}," operation to be silently ignored for that row.",[272,1187,1189],{"className":274,"code":1188,"language":276,"meta":277,"style":277},"// If a user with this email already exists, this query does nothing.\nawait db.insert(users)\n  .values({ fullName: 'Jane Doe', email: 'jane.doe@example.com' })\n  .onConflictDoNothing()\n  .execute();\n",[247,1190,1191,1196,1208,1246,1256],{"__ignoreMap":277},[281,1192,1193],{"class":283,"line":284},[281,1194,1195],{"class":351},"// If a user with this email already exists, this query does nothing.\n",[281,1197,1198,1200,1202,1204,1206],{"class":283,"line":318},[281,1199,543],{"class":287},[281,1201,296],{"class":295},[281,1203,455],{"class":291},[281,1205,459],{"class":458},[281,1207,700],{"class":295},[281,1209,1210,1212,1214,1216,1218,1220,1222,1224,1227,1229,1231,1233,1235,1237,1240,1242,1244],{"class":283,"line":341},[281,1211,705],{"class":291},[281,1213,467],{"class":458},[281,1215,710],{"class":295},[281,1217,713],{"class":291},[281,1219,566],{"class":395},[281,1221,371],{"class":291},[281,1223,305],{"class":291},[281,1225,1226],{"class":308},"Jane Doe",[281,1228,312],{"class":291},[281,1230,578],{"class":291},[281,1232,581],{"class":395},[281,1234,371],{"class":291},[281,1236,305],{"class":291},[281,1238,1239],{"class":308},"jane.doe@example.com",[281,1241,312],{"class":291},[281,1243,299],{"class":291},[281,1245,742],{"class":295},[281,1247,1248,1250,1253],{"class":283,"line":348},[281,1249,705],{"class":291},[281,1251,1252],{"class":458},"onConflictDoNothing",[281,1254,1255],{"class":295},"()\n",[281,1257,1258,1260,1262,1264],{"class":283,"line":355},[281,1259,705],{"class":291},[281,1261,475],{"class":458},[281,1263,478],{"class":295},[281,1265,315],{"class":291},[659,1267,1269],{"id":1268},"onconflictdoupdate",[247,1270,1271],{},".onConflictDoUpdate()",[243,1273,1274,1275,1278],{},"This enables \"upsert\" (update or insert) functionality. If a conflict occurs, it instead performs an ",[247,1276,1277],{},"UPDATE"," on the existing row.",[272,1280,1282],{"className":274,"code":1281,"language":276,"meta":277,"style":277},"// If a user with this email exists, update their name.\n// Otherwise, insert a new user with this name and email.\nawait db.insert(users)\n  .values({ fullName: 'John Smith (Updated)', email: 'john.smith@example.com'})\n  .onConflictDoUpdate({\n    target: users._.columns.email, // The column with the UNIQUE constraint\n    set: {\n      fullName: 'John Smith (Updated)', // Values to set on update\n    }\n  })\n  .execute();\n",[247,1283,1284,1289,1294,1306,1344,1356,1385,1394,1412,1417,1424],{"__ignoreMap":277},[281,1285,1286],{"class":283,"line":284},[281,1287,1288],{"class":351},"// If a user with this email exists, update their name.\n",[281,1290,1291],{"class":283,"line":318},[281,1292,1293],{"class":351},"// Otherwise, insert a new user with this name and email.\n",[281,1295,1296,1298,1300,1302,1304],{"class":283,"line":341},[281,1297,543],{"class":287},[281,1299,296],{"class":295},[281,1301,455],{"class":291},[281,1303,459],{"class":458},[281,1305,700],{"class":295},[281,1307,1308,1310,1312,1314,1316,1318,1320,1322,1325,1327,1329,1331,1333,1335,1337,1339,1342],{"class":283,"line":348},[281,1309,705],{"class":291},[281,1311,467],{"class":458},[281,1313,710],{"class":295},[281,1315,713],{"class":291},[281,1317,566],{"class":395},[281,1319,371],{"class":291},[281,1321,305],{"class":291},[281,1323,1324],{"class":308},"John Smith (Updated)",[281,1326,312],{"class":291},[281,1328,578],{"class":291},[281,1330,581],{"class":395},[281,1332,371],{"class":291},[281,1334,305],{"class":291},[281,1336,421],{"class":308},[281,1338,312],{"class":291},[281,1340,1341],{"class":291},"}",[281,1343,742],{"class":295},[281,1345,1346,1348,1351,1353],{"class":283,"line":355},[281,1347,705],{"class":291},[281,1349,1350],{"class":458},"onConflictDoUpdate",[281,1352,710],{"class":295},[281,1354,1355],{"class":291},"{\n",[281,1357,1358,1361,1363,1365,1367,1370,1372,1375,1377,1380,1382],{"class":283,"line":361},[281,1359,1360],{"class":395},"    target",[281,1362,371],{"class":291},[281,1364,325],{"class":295},[281,1366,455],{"class":291},[281,1368,1369],{"class":295},"_",[281,1371,455],{"class":291},[281,1373,1374],{"class":295},"columns",[281,1376,455],{"class":291},[281,1378,1379],{"class":295},"email",[281,1381,578],{"class":291},[281,1383,1384],{"class":351}," // The column with the UNIQUE constraint\n",[281,1386,1387,1390,1392],{"class":283,"line":392},[281,1388,1389],{"class":395},"    set",[281,1391,371],{"class":291},[281,1393,389],{"class":291},[281,1395,1396,1399,1401,1403,1405,1407,1409],{"class":283,"line":411},[281,1397,1398],{"class":395},"      fullName",[281,1400,371],{"class":291},[281,1402,305],{"class":291},[281,1404,1324],{"class":308},[281,1406,312],{"class":291},[281,1408,578],{"class":291},[281,1410,1411],{"class":351}," // Values to set on update\n",[281,1413,1414],{"class":283,"line":428},[281,1415,1416],{"class":291},"    }\n",[281,1418,1419,1422],{"class":283,"line":434},[281,1420,1421],{"class":291},"  }",[281,1423,742],{"class":295},[281,1425,1426,1428,1430,1432],{"class":283,"line":439},[281,1427,705],{"class":291},[281,1429,475],{"class":458},[281,1431,478],{"class":295},[281,1433,315],{"class":291},[659,1435,1437],{"id":1436},"upsert-shorthand","Upsert Shorthand",[243,1439,1440,1441,1444],{},"For simple upserts, use the ",[247,1442,1443],{},".upsert()"," helper:",[272,1446,1448],{"className":274,"code":1447,"language":276,"meta":277,"style":277},"// Insert or update user by email\nawait db.upsert(\n  users,\n  { fullName: 'John Doe', email: 'john@example.com' },\n  ['email']  // Conflict target (unique column)\n);\n",[247,1449,1450,1455,1469,1476,1506,1523],{"__ignoreMap":277},[281,1451,1452],{"class":283,"line":284},[281,1453,1454],{"class":351},"// Insert or update user by email\n",[281,1456,1457,1459,1461,1463,1466],{"class":283,"line":318},[281,1458,543],{"class":287},[281,1460,296],{"class":295},[281,1462,455],{"class":291},[281,1464,1465],{"class":458},"upsert",[281,1467,1468],{"class":295},"(\n",[281,1470,1471,1474],{"class":283,"line":341},[281,1472,1473],{"class":295},"  users",[281,1475,408],{"class":291},[281,1477,1478,1480,1482,1484,1486,1489,1491,1493,1495,1497,1499,1502,1504],{"class":283,"line":348},[281,1479,563],{"class":291},[281,1481,566],{"class":395},[281,1483,371],{"class":291},[281,1485,305],{"class":291},[281,1487,1488],{"class":308},"John Doe",[281,1490,312],{"class":291},[281,1492,578],{"class":291},[281,1494,581],{"class":395},[281,1496,371],{"class":291},[281,1498,305],{"class":291},[281,1500,1501],{"class":308},"john@example.com",[281,1503,312],{"class":291},[281,1505,593],{"class":291},[281,1507,1508,1511,1513,1515,1517,1520],{"class":283,"line":355},[281,1509,1510],{"class":295},"  [",[281,1512,312],{"class":291},[281,1514,1379],{"class":308},[281,1516,312],{"class":291},[281,1518,1519],{"class":295},"]  ",[281,1521,1522],{"class":351},"// Conflict target (unique column)\n",[281,1524,1525,1527],{"class":283,"line":361},[281,1526,1038],{"class":295},[281,1528,315],{"class":291},[1530,1531,1532],"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 .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}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 .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}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);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}",{"title":277,"searchDepth":318,"depth":318,"links":1534},[1535,1536,1537,1546],{"id":258,"depth":318,"text":259},{"id":527,"depth":318,"text":528},{"id":639,"depth":318,"text":640,"children":1538},[1539,1541,1543,1545],{"id":661,"depth":341,"text":1540},".returningFirst() - Most Common Use Case",{"id":788,"depth":341,"text":1542},".returningAll() - For Multiple Rows",{"id":943,"depth":341,"text":1544},".returning() - For Specific Columns",{"id":1063,"depth":341,"text":1064},{"id":1157,"depth":318,"text":1158,"children":1547},[1548,1549,1550],{"id":1176,"depth":341,"text":1179},{"id":1268,"depth":341,"text":1271},{"id":1436,"depth":341,"text":1437},"Inserting data using Tauri SQLite ORM.","md",null,{},{"title":172,"description":1551},"PKxcGoEbrnyf7FTI_17xfDgd2fuQzkzx8C151M38qQA",[1558,1560],{"title":168,"path":169,"stem":170,"description":1559,"children":-1},"Selecting data using Tauri SQLite ORM.",{"title":176,"path":177,"stem":178,"description":1561,"children":-1},"Updating data using Tauri SQLite ORM.",1773317302161]