[{"data":1,"prerenderedAt":1691},["ShallowReactive",2],{"navigation":3,"-docs-database":394,"-docs-database-surround":1686},[4,88,217,223,379,391],{"title":5,"path":6,"stem":7,"children":8,"icon":87},"","/docs","1.docs/1.index",[9,12,17,22,27,32,37,42,47,52,57,62,67,72,77,82],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-compass",{"title":13,"path":14,"stem":15,"icon":16},"Quick Start","/docs/quick-start","1.docs/2.quick-start","i-lucide-zap",{"title":18,"path":19,"stem":20,"icon":21},"Renderer","/docs/renderer","1.docs/4.renderer","ri:layout-masonry-line",{"title":23,"path":24,"stem":25,"icon":26},"Routing","/docs/routing","1.docs/5.routing","ri:direction-line",{"title":28,"path":29,"stem":30,"icon":31},"Assets","/docs/assets","1.docs/50.assets","ri:image-2-line",{"title":33,"path":34,"stem":35,"icon":36},"Configuration","/docs/configuration","1.docs/50.configuration","ri:settings-3-line",{"title":38,"path":39,"stem":40,"icon":41},"Database","/docs/database","1.docs/50.database","ri:database-2-line",{"title":43,"path":44,"stem":45,"icon":46},"Lifecycle","/docs/lifecycle","1.docs/50.lifecycle","i-lucide-layers",{"title":48,"path":49,"stem":50,"icon":51},"OpenAPI","/docs/openapi","1.docs/50.openapi","ri:contract-line",{"title":53,"path":54,"stem":55,"icon":56},"Plugins","/docs/plugins","1.docs/50.plugins","ri:plug-line",{"title":58,"path":59,"stem":60,"icon":61},"Tasks","/docs/tasks","1.docs/50.tasks","codicon:run-all",{"title":63,"path":64,"stem":65,"icon":66},"Server Entry","/docs/server-entry","1.docs/6.server-entry","ri:server-line",{"title":68,"path":69,"stem":70,"icon":71},"Cache","/docs/cache","1.docs/7.cache","ri:speed-line",{"title":73,"path":74,"stem":75,"icon":76},"KV Storage","/docs/storage","1.docs/8.storage","carbon:datastore",{"title":78,"path":79,"stem":80,"icon":81},"Migration Guide","/docs/migration","1.docs/99.migration","ri:arrow-right-up-line",{"title":83,"path":84,"stem":85,"icon":86},"Nightly Channel","/docs/nightly","1.docs/99.nightly","ri:moon-fill","i-lucide-book-open",{"title":89,"path":90,"stem":91,"children":92,"icon":94},"Deploy","/deploy","2.deploy/0.index",[93,95,116],{"title":89,"path":90,"stem":91,"icon":94},"ri:upload-cloud-2-line",{"title":96,"path":97,"stem":98,"children":99,"page":115},"Runtimes","/deploy/runtimes","2.deploy/10.runtimes",[100,105,110],{"title":101,"path":102,"stem":103,"icon":104},"Node.js","/deploy/runtimes/node","2.deploy/10.runtimes/1.node","akar-icons:node-fill",{"title":106,"path":107,"stem":108,"icon":109},"Bun","/deploy/runtimes/bun","2.deploy/10.runtimes/bun","simple-icons:bun",{"title":111,"path":112,"stem":113,"icon":114},"Deno","/deploy/runtimes/deno","2.deploy/10.runtimes/deno","simple-icons:deno",false,{"title":117,"path":118,"stem":119,"children":120,"page":115},"Providers","/deploy/providers","2.deploy/20.providers",[121,125,129,133,137,141,145,149,153,157,161,165,169,173,177,181,185,189,193,197,201,205,209,213],{"title":122,"path":123,"stem":124},"Alwaysdata","/deploy/providers/alwaysdata","2.deploy/20.providers/alwaysdata",{"title":126,"path":127,"stem":128},"AWS Lambda","/deploy/providers/aws","2.deploy/20.providers/aws",{"title":130,"path":131,"stem":132},"AWS Amplify","/deploy/providers/aws-amplify","2.deploy/20.providers/aws-amplify",{"title":134,"path":135,"stem":136},"Azure","/deploy/providers/azure","2.deploy/20.providers/azure",{"title":138,"path":139,"stem":140},"Cleavr","/deploy/providers/cleavr","2.deploy/20.providers/cleavr",{"title":142,"path":143,"stem":144},"Cloudflare","/deploy/providers/cloudflare","2.deploy/20.providers/cloudflare",{"title":146,"path":147,"stem":148},"Deno Deploy","/deploy/providers/deno-deploy","2.deploy/20.providers/deno-deploy",{"title":150,"path":151,"stem":152},"DigitalOcean","/deploy/providers/digitalocean","2.deploy/20.providers/digitalocean",{"title":154,"path":155,"stem":156},"Firebase","/deploy/providers/firebase","2.deploy/20.providers/firebase",{"title":158,"path":159,"stem":160},"Flightcontrol","/deploy/providers/flightcontrol","2.deploy/20.providers/flightcontrol",{"title":162,"path":163,"stem":164},"Genezio","/deploy/providers/genezio","2.deploy/20.providers/genezio",{"title":166,"path":167,"stem":168},"GitHub Pages","/deploy/providers/github-pages","2.deploy/20.providers/github-pages",{"title":170,"path":171,"stem":172},"GitLab Pages","/deploy/providers/gitlab-pages","2.deploy/20.providers/gitlab-pages",{"title":174,"path":175,"stem":176},"Heroku","/deploy/providers/heroku","2.deploy/20.providers/heroku",{"title":178,"path":179,"stem":180},"IIS","/deploy/providers/iis","2.deploy/20.providers/iis",{"title":182,"path":183,"stem":184},"Koyeb","/deploy/providers/koyeb","2.deploy/20.providers/koyeb",{"title":186,"path":187,"stem":188},"Netlify","/deploy/providers/netlify","2.deploy/20.providers/netlify",{"title":190,"path":191,"stem":192},"Platform.sh","/deploy/providers/platform-sh","2.deploy/20.providers/platform-sh",{"title":194,"path":195,"stem":196},"Render.com","/deploy/providers/render","2.deploy/20.providers/render",{"title":198,"path":199,"stem":200},"StormKit","/deploy/providers/stormkit","2.deploy/20.providers/stormkit",{"title":202,"path":203,"stem":204},"Vercel","/deploy/providers/vercel","2.deploy/20.providers/vercel",{"title":206,"path":207,"stem":208},"Zeabur","/deploy/providers/zeabur","2.deploy/20.providers/zeabur",{"title":210,"path":211,"stem":212},"Zephyr Cloud","/deploy/providers/zephyr","2.deploy/20.providers/zephyr",{"title":214,"path":215,"stem":216},"Zerops","/deploy/providers/zerops","2.deploy/20.providers/zerops",{"title":218,"path":219,"stem":220,"children":221,"icon":36},"Config","/config","3.config/0.index",[222],{"title":218,"path":219,"stem":220,"icon":36},{"title":224,"path":225,"stem":226,"children":227,"icon":229},"Examples","/examples","4.examples/0.index",[228,230,235,240,245,250,254,259,264,269,274,279,284,288,293,297,301,306,311,316,321,326,331,336,341,346,350,355,360,364,369,374],{"title":224,"path":225,"stem":226,"icon":229},"i-lucide-folder-code",{"title":231,"path":232,"stem":233,"icon":234},"API Routes","/examples/api-routes","4.examples/api-routes","i-lucide-route",{"title":236,"path":237,"stem":238,"icon":239},"Auto Imports","/examples/auto-imports","4.examples/auto-imports","i-lucide-import",{"title":241,"path":242,"stem":243,"icon":244},"Cached Handler","/examples/cached-handler","4.examples/cached-handler","i-lucide-clock",{"title":246,"path":247,"stem":248,"icon":249},"Custom Error Handler","/examples/custom-error-handler","4.examples/custom-error-handler","i-lucide-alert-circle",{"title":38,"path":251,"stem":252,"icon":253},"/examples/database","4.examples/database","i-lucide-database",{"title":255,"path":256,"stem":257,"icon":258},"Elysia","/examples/elysia","4.examples/elysia","i-skill-icons-elysia-dark",{"title":260,"path":261,"stem":262,"icon":263},"Express","/examples/express","4.examples/express","i-simple-icons-express",{"title":265,"path":266,"stem":267,"icon":268},"Fastify","/examples/fastify","4.examples/fastify","i-simple-icons-fastify",{"title":270,"path":271,"stem":272,"icon":273},"Hello World","/examples/hello-world","4.examples/hello-world","i-lucide-sparkles",{"title":275,"path":276,"stem":277,"icon":278},"Hono","/examples/hono","4.examples/hono","i-logos-hono",{"title":280,"path":281,"stem":282,"icon":283},"Import Alias","/examples/import-alias","4.examples/import-alias","i-lucide-at-sign",{"title":285,"path":286,"stem":287,"icon":46},"Middleware","/examples/middleware","4.examples/middleware",{"title":289,"path":290,"stem":291,"icon":292},"Mono JSX","/examples/mono-jsx","4.examples/mono-jsx","i-lucide-brackets",{"title":294,"path":295,"stem":296,"icon":292},"Nano JSX","/examples/nano-jsx","4.examples/nano-jsx",{"title":53,"path":298,"stem":299,"icon":300},"/examples/plugins","4.examples/plugins","i-lucide-plug",{"title":302,"path":303,"stem":304,"icon":305},"Custom Renderer","/examples/renderer","4.examples/renderer","i-lucide-code",{"title":307,"path":308,"stem":309,"icon":310},"Runtime Config","/examples/runtime-config","4.examples/runtime-config","i-lucide-settings",{"title":312,"path":313,"stem":314,"icon":315},"Server Fetch","/examples/server-fetch","4.examples/server-fetch","i-lucide-arrow-right-left",{"title":317,"path":318,"stem":319,"icon":320},"Shiki","/examples/shiki","4.examples/shiki","i-lucide-highlighter",{"title":322,"path":323,"stem":324,"icon":325},"Virtual Routes","/examples/virtual-routes","4.examples/virtual-routes","i-lucide-box",{"title":327,"path":328,"stem":329,"icon":330},"Vite Nitro Plugin","/examples/vite-nitro-plugin","4.examples/vite-nitro-plugin","i-logos-vitejs",{"title":332,"path":333,"stem":334,"icon":335},"Vite RSC","/examples/vite-rsc","4.examples/vite-rsc","i-logos-react",{"title":337,"path":338,"stem":339,"icon":340},"Vite SSR HTML","/examples/vite-ssr-html","4.examples/vite-ssr-html","i-logos-html-5",{"title":342,"path":343,"stem":344,"icon":345},"SSR with Preact","/examples/vite-ssr-preact","4.examples/vite-ssr-preact","i-logos-preact",{"title":347,"path":348,"stem":349,"icon":335},"SSR with React","/examples/vite-ssr-react","4.examples/vite-ssr-react",{"title":351,"path":352,"stem":353,"icon":354},"SSR with SolidJS","/examples/vite-ssr-solid","4.examples/vite-ssr-solid","i-logos-solidjs-icon",{"title":356,"path":357,"stem":358,"icon":359},"SSR with TanStack Router","/examples/vite-ssr-tsr-react","4.examples/vite-ssr-tsr-react","i-simple-icons-tanstack",{"title":361,"path":362,"stem":363,"icon":359},"SSR with TanStack Start","/examples/vite-ssr-tss-react","4.examples/vite-ssr-tss-react",{"title":365,"path":366,"stem":367,"icon":368},"SSR with Vue Router","/examples/vite-ssr-vue-router","4.examples/vite-ssr-vue-router","i-logos-vue",{"title":370,"path":371,"stem":372,"icon":373},"Vite + tRPC","/examples/vite-trpc","4.examples/vite-trpc","i-simple-icons-trpc",{"title":375,"path":376,"stem":377,"icon":378},"WebSocket","/examples/websocket","4.examples/websocket","i-lucide-radio",{"title":380,"path":381,"stem":382,"children":383},"Blog","/blog","9.blog",[384,387],{"title":380,"path":381,"stem":385,"icon":386},"9.blog/index","i-lucide-file-text",{"title":388,"path":389,"stem":390,"icon":386},"Nitro v3 Beta is here!","/blog/v3-beta","9.blog/1.v3-beta",{"title":5,"path":392,"stem":393},"/","index",{"id":395,"title":38,"body":396,"description":1680,"extension":1681,"meta":1682,"navigation":1683,"path":39,"seo":1684,"stem":40,"__hash__":1685},"content/1.docs/50.database.md",{"type":397,"value":398,"toc":1668,"icon":41},"minimark",[399,421,426,438,441,524,534,544,549,812,819,829,896,909,912,918,921,1049,1055,1058,1095,1101,1104,1174,1177,1184,1297,1301,1312,1421,1434,1438,1451,1664],[400,401,402,403,407,408,415,416,420],"p",{},"The default database connection is ",[404,405,406],"strong",{},"preconfigured"," with ",[409,410,414],"a",{"href":411,"rel":412},"https://db0.unjs.io/connectors/sqlite",[413],"nofollow","SQLite"," and works out of the box for development mode and any Node.js compatible production deployments. By default, data will be stored in ",[417,418,419],"code",{},".data/db.sqlite",".",[422,423],"read-more",{"title":424,"to":425},"DB0 Documentation","https://db0.unjs.io",[427,428,429],"important",{},[400,430,431,432,437],{},"\nDatabase support is currently experimental.\nRefer to the ",[409,433,436],{"href":434,"rel":435},"https://github.com/unjs/db0/issues",[413],"db0 issues"," for status and bug report.",[400,439,440],{},"In order to enable database layer you need to enable experimental feature flag.",[442,443,448],"pre",{"className":444,"code":445,"filename":446,"language":447,"meta":5,"style":5},"language-ts shiki shiki-themes github-light github-dark github-dark","import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  experimental: {\n    database: true\n  }\n})\n","nitro.config.ts","ts",[417,449,450,473,480,496,502,512,518],{"__ignoreMap":5},[451,452,455,459,463,466,470],"span",{"class":453,"line":454},"line",1,[451,456,458],{"class":457},"so5gQ","import",[451,460,462],{"class":461},"slsVL"," { defineNitroConfig } ",[451,464,465],{"class":457},"from",[451,467,469],{"class":468},"sfrk1"," \"nitro/config\"",[451,471,472],{"class":461},";\n",[451,474,476],{"class":453,"line":475},2,[451,477,479],{"emptyLinePlaceholder":478},true,"\n",[451,481,483,486,489,493],{"class":453,"line":482},3,[451,484,485],{"class":457},"export",[451,487,488],{"class":457}," default",[451,490,492],{"class":491},"shcOC"," defineNitroConfig",[451,494,495],{"class":461},"({\n",[451,497,499],{"class":453,"line":498},4,[451,500,501],{"class":461},"  experimental: {\n",[451,503,505,508],{"class":453,"line":504},5,[451,506,507],{"class":461},"    database: ",[451,509,511],{"class":510},"suiK_","true\n",[451,513,515],{"class":453,"line":514},6,[451,516,517],{"class":461},"  }\n",[451,519,521],{"class":453,"line":520},7,[451,522,523],{"class":461},"})\n",[525,526,527],"tip",{},[400,528,529,530,420],{},"\nYou can change default connection or define more connections to any of the ",[409,531,533],{"href":411,"rel":532},[413],"supported databases",[525,535,536],{},[400,537,538,539,420],{},"\nYou can integrate database instance to any of the ",[409,540,543],{"href":541,"rel":542},"https://db0.unjs.io/integrations",[413],"supported ORMs",[545,546,548],"h2",{"id":547},"usage","Usage",[442,550,553],{"className":444,"code":551,"filename":552,"language":447,"meta":5,"style":5},"import { defineHandler } from \"nitro\";\nimport { useDatabase } from \"nitro/database\";\n\nexport default defineHandler(async () => {\n  const db = useDatabase();\n\n  // Create users table\n  await db.sql`DROP TABLE IF EXISTS users`;\n  await db.sql`CREATE TABLE IF NOT EXISTS users (\"id\" TEXT PRIMARY KEY, \"firstName\" TEXT, \"lastName\" TEXT, \"email\" TEXT)`;\n\n  // Add a new user\n  const userId = String(Math.round(Math.random() * 10_000));\n  await db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;\n\n  // Query for users\n  const { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;\n\n  return {\n    rows,\n  };\n});\n","server.ts",[417,554,555,569,583,587,611,628,632,638,655,669,674,680,716,736,741,747,781,786,794,800,806],{"__ignoreMap":5},[451,556,557,559,562,564,567],{"class":453,"line":454},[451,558,458],{"class":457},[451,560,561],{"class":461}," { defineHandler } ",[451,563,465],{"class":457},[451,565,566],{"class":468}," \"nitro\"",[451,568,472],{"class":461},[451,570,571,573,576,578,581],{"class":453,"line":475},[451,572,458],{"class":457},[451,574,575],{"class":461}," { useDatabase } ",[451,577,465],{"class":457},[451,579,580],{"class":468}," \"nitro/database\"",[451,582,472],{"class":461},[451,584,585],{"class":453,"line":482},[451,586,479],{"emptyLinePlaceholder":478},[451,588,589,591,593,596,599,602,605,608],{"class":453,"line":498},[451,590,485],{"class":457},[451,592,488],{"class":457},[451,594,595],{"class":491}," defineHandler",[451,597,598],{"class":461},"(",[451,600,601],{"class":457},"async",[451,603,604],{"class":461}," () ",[451,606,607],{"class":457},"=>",[451,609,610],{"class":461}," {\n",[451,612,613,616,619,622,625],{"class":453,"line":504},[451,614,615],{"class":457},"  const",[451,617,618],{"class":510}," db",[451,620,621],{"class":457}," =",[451,623,624],{"class":491}," useDatabase",[451,626,627],{"class":461},"();\n",[451,629,630],{"class":453,"line":514},[451,631,479],{"emptyLinePlaceholder":478},[451,633,634],{"class":453,"line":520},[451,635,637],{"class":636},"sCsY4","  // Create users table\n",[451,639,641,644,647,650,653],{"class":453,"line":640},8,[451,642,643],{"class":457},"  await",[451,645,646],{"class":461}," db.",[451,648,649],{"class":491},"sql",[451,651,652],{"class":468},"`DROP TABLE IF EXISTS users`",[451,654,472],{"class":461},[451,656,658,660,662,664,667],{"class":453,"line":657},9,[451,659,643],{"class":457},[451,661,646],{"class":461},[451,663,649],{"class":491},[451,665,666],{"class":468},"`CREATE TABLE IF NOT EXISTS users (\"id\" TEXT PRIMARY KEY, \"firstName\" TEXT, \"lastName\" TEXT, \"email\" TEXT)`",[451,668,472],{"class":461},[451,670,672],{"class":453,"line":671},10,[451,673,479],{"emptyLinePlaceholder":478},[451,675,677],{"class":453,"line":676},11,[451,678,679],{"class":636},"  // Add a new user\n",[451,681,683,685,688,690,693,696,699,701,704,707,710,713],{"class":453,"line":682},12,[451,684,615],{"class":457},[451,686,687],{"class":510}," userId",[451,689,621],{"class":457},[451,691,692],{"class":491}," String",[451,694,695],{"class":461},"(Math.",[451,697,698],{"class":491},"round",[451,700,695],{"class":461},[451,702,703],{"class":491},"random",[451,705,706],{"class":461},"() ",[451,708,709],{"class":457},"*",[451,711,712],{"class":510}," 10_000",[451,714,715],{"class":461},"));\n",[451,717,719,721,723,725,728,731,734],{"class":453,"line":718},13,[451,720,643],{"class":457},[451,722,646],{"class":461},[451,724,649],{"class":491},[451,726,727],{"class":468},"`INSERT INTO users VALUES (${",[451,729,730],{"class":461},"userId",[451,732,733],{"class":468},"}, 'John', 'Doe', '')`",[451,735,472],{"class":461},[451,737,739],{"class":453,"line":738},14,[451,740,479],{"emptyLinePlaceholder":478},[451,742,744],{"class":453,"line":743},15,[451,745,746],{"class":636},"  // Query for users\n",[451,748,750,752,755,758,761,764,767,769,771,774,776,779],{"class":453,"line":749},16,[451,751,615],{"class":457},[451,753,754],{"class":461}," { ",[451,756,757],{"class":510},"rows",[451,759,760],{"class":461}," } ",[451,762,763],{"class":457},"=",[451,765,766],{"class":457}," await",[451,768,646],{"class":461},[451,770,649],{"class":491},[451,772,773],{"class":468},"`SELECT * FROM users WHERE id = ${",[451,775,730],{"class":461},[451,777,778],{"class":468},"}`",[451,780,472],{"class":461},[451,782,784],{"class":453,"line":783},17,[451,785,479],{"emptyLinePlaceholder":478},[451,787,789,792],{"class":453,"line":788},18,[451,790,791],{"class":457},"  return",[451,793,610],{"class":461},[451,795,797],{"class":453,"line":796},19,[451,798,799],{"class":461},"    rows,\n",[451,801,803],{"class":453,"line":802},20,[451,804,805],{"class":461},"  };\n",[451,807,809],{"class":453,"line":808},21,[451,810,811],{"class":461},"});\n",[813,814,816],"h3",{"id":815},"usedatabase",[417,817,818],{},"useDatabase",[400,820,821,822,824,825,828],{},"Use ",[417,823,818],{}," to get a database instance. It accepts an optional connection name (defaults to ",[417,826,827],{},"\"default\"",").",[442,830,832],{"className":444,"code":831,"language":447,"meta":5,"style":5},"import { useDatabase } from \"nitro/database\";\n\n// Use the default connection\nconst db = useDatabase();\n\n// Use a named connection\nconst usersDb = useDatabase(\"users\");\n",[417,833,834,846,850,855,868,872,877],{"__ignoreMap":5},[451,835,836,838,840,842,844],{"class":453,"line":454},[451,837,458],{"class":457},[451,839,575],{"class":461},[451,841,465],{"class":457},[451,843,580],{"class":468},[451,845,472],{"class":461},[451,847,848],{"class":453,"line":475},[451,849,479],{"emptyLinePlaceholder":478},[451,851,852],{"class":453,"line":482},[451,853,854],{"class":636},"// Use the default connection\n",[451,856,857,860,862,864,866],{"class":453,"line":498},[451,858,859],{"class":457},"const",[451,861,618],{"class":510},[451,863,621],{"class":457},[451,865,624],{"class":491},[451,867,627],{"class":461},[451,869,870],{"class":453,"line":504},[451,871,479],{"emptyLinePlaceholder":478},[451,873,874],{"class":453,"line":514},[451,875,876],{"class":636},"// Use a named connection\n",[451,878,879,881,884,886,888,890,893],{"class":453,"line":520},[451,880,859],{"class":457},[451,882,883],{"class":510}," usersDb",[451,885,621],{"class":457},[451,887,624],{"class":491},[451,889,598],{"class":461},[451,891,892],{"class":468},"\"users\"",[451,894,895],{"class":461},");\n",[897,898,899],"note",{},[400,900,901,902,905,906,908],{},"\nWhen ",[417,903,904],{},"experimental.database"," is enabled, ",[417,907,818],{}," is auto-imported and available without an explicit import statement.",[400,910,911],{},"Database instances are created lazily on first use and cached for subsequent calls with the same connection name. If a connection name is not configured, an error will be thrown.",[813,913,915],{"id":914},"dbsql",[417,916,917],{},"db.sql",[400,919,920],{},"Execute SQL queries using tagged template literals with automatic parameter binding:",[442,922,924],{"className":444,"code":923,"language":447,"meta":5,"style":5},"const db = useDatabase();\n\n// Insert with parameterized values (safe from SQL injection)\nconst id = \"1001\";\nawait db.sql`INSERT INTO users VALUES (${id}, 'John', 'Doe', 'john@example.com')`;\n\n// Query with parameters\nconst { rows } = await db.sql`SELECT * FROM users WHERE id = ${id}`;\n\n// The result includes rows, changes count, and last insert ID\nconst result = await db.sql`INSERT INTO posts (title) VALUES (${\"Hello\"})`;\n// result.rows, result.changes, result.lastInsertRowid\n",[417,925,926,938,942,947,961,980,984,989,1015,1019,1024,1044],{"__ignoreMap":5},[451,927,928,930,932,934,936],{"class":453,"line":454},[451,929,859],{"class":457},[451,931,618],{"class":510},[451,933,621],{"class":457},[451,935,624],{"class":491},[451,937,627],{"class":461},[451,939,940],{"class":453,"line":475},[451,941,479],{"emptyLinePlaceholder":478},[451,943,944],{"class":453,"line":482},[451,945,946],{"class":636},"// Insert with parameterized values (safe from SQL injection)\n",[451,948,949,951,954,956,959],{"class":453,"line":498},[451,950,859],{"class":457},[451,952,953],{"class":510}," id",[451,955,621],{"class":457},[451,957,958],{"class":468}," \"1001\"",[451,960,472],{"class":461},[451,962,963,966,968,970,972,975,978],{"class":453,"line":504},[451,964,965],{"class":457},"await",[451,967,646],{"class":461},[451,969,649],{"class":491},[451,971,727],{"class":468},[451,973,974],{"class":461},"id",[451,976,977],{"class":468},"}, 'John', 'Doe', 'john@example.com')`",[451,979,472],{"class":461},[451,981,982],{"class":453,"line":514},[451,983,479],{"emptyLinePlaceholder":478},[451,985,986],{"class":453,"line":520},[451,987,988],{"class":636},"// Query with parameters\n",[451,990,991,993,995,997,999,1001,1003,1005,1007,1009,1011,1013],{"class":453,"line":640},[451,992,859],{"class":457},[451,994,754],{"class":461},[451,996,757],{"class":510},[451,998,760],{"class":461},[451,1000,763],{"class":457},[451,1002,766],{"class":457},[451,1004,646],{"class":461},[451,1006,649],{"class":491},[451,1008,773],{"class":468},[451,1010,974],{"class":461},[451,1012,778],{"class":468},[451,1014,472],{"class":461},[451,1016,1017],{"class":453,"line":657},[451,1018,479],{"emptyLinePlaceholder":478},[451,1020,1021],{"class":453,"line":671},[451,1022,1023],{"class":636},"// The result includes rows, changes count, and last insert ID\n",[451,1025,1026,1028,1031,1033,1035,1037,1039,1042],{"class":453,"line":676},[451,1027,859],{"class":457},[451,1029,1030],{"class":510}," result",[451,1032,621],{"class":457},[451,1034,766],{"class":457},[451,1036,646],{"class":461},[451,1038,649],{"class":491},[451,1040,1041],{"class":468},"`INSERT INTO posts (title) VALUES (${\"Hello\"})`",[451,1043,472],{"class":461},[451,1045,1046],{"class":453,"line":682},[451,1047,1048],{"class":636},"// result.rows, result.changes, result.lastInsertRowid\n",[813,1050,1052],{"id":1051},"dbexec",[417,1053,1054],{},"db.exec",[400,1056,1057],{},"Execute a raw SQL string directly:",[442,1059,1061],{"className":444,"code":1060,"language":447,"meta":5,"style":5},"const db = useDatabase();\n\nawait db.exec(\"CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, name TEXT)\");\n",[417,1062,1063,1075,1079],{"__ignoreMap":5},[451,1064,1065,1067,1069,1071,1073],{"class":453,"line":454},[451,1066,859],{"class":457},[451,1068,618],{"class":510},[451,1070,621],{"class":457},[451,1072,624],{"class":491},[451,1074,627],{"class":461},[451,1076,1077],{"class":453,"line":475},[451,1078,479],{"emptyLinePlaceholder":478},[451,1080,1081,1083,1085,1088,1090,1093],{"class":453,"line":482},[451,1082,965],{"class":457},[451,1084,646],{"class":461},[451,1086,1087],{"class":491},"exec",[451,1089,598],{"class":461},[451,1091,1092],{"class":468},"\"CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, name TEXT)\"",[451,1094,895],{"class":461},[813,1096,1098],{"id":1097},"dbprepare",[417,1099,1100],{},"db.prepare",[400,1102,1103],{},"Prepare an SQL statement for repeated execution:",[442,1105,1107],{"className":444,"code":1106,"language":447,"meta":5,"style":5},"const db = useDatabase();\n\nconst stmt = db.prepare(\"SELECT * FROM users WHERE id = ?\");\nconst result = await stmt.bind(\"1001\").all();\n",[417,1108,1109,1121,1125,1146],{"__ignoreMap":5},[451,1110,1111,1113,1115,1117,1119],{"class":453,"line":454},[451,1112,859],{"class":457},[451,1114,618],{"class":510},[451,1116,621],{"class":457},[451,1118,624],{"class":491},[451,1120,627],{"class":461},[451,1122,1123],{"class":453,"line":475},[451,1124,479],{"emptyLinePlaceholder":478},[451,1126,1127,1129,1132,1134,1136,1139,1141,1144],{"class":453,"line":482},[451,1128,859],{"class":457},[451,1130,1131],{"class":510}," stmt",[451,1133,621],{"class":457},[451,1135,646],{"class":461},[451,1137,1138],{"class":491},"prepare",[451,1140,598],{"class":461},[451,1142,1143],{"class":468},"\"SELECT * FROM users WHERE id = ?\"",[451,1145,895],{"class":461},[451,1147,1148,1150,1152,1154,1156,1159,1162,1164,1167,1169,1172],{"class":453,"line":498},[451,1149,859],{"class":457},[451,1151,1030],{"class":510},[451,1153,621],{"class":457},[451,1155,766],{"class":457},[451,1157,1158],{"class":461}," stmt.",[451,1160,1161],{"class":491},"bind",[451,1163,598],{"class":461},[451,1165,1166],{"class":468},"\"1001\"",[451,1168,828],{"class":461},[451,1170,1171],{"class":491},"all",[451,1173,627],{"class":461},[545,1175,33],{"id":1176},"configuration",[400,1178,1179,1180,1183],{},"You can configure database connections using ",[417,1181,1182],{},"database"," config:",[442,1185,1187],{"className":444,"code":1186,"filename":446,"language":447,"meta":5,"style":5},"import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  database: {\n    default: {\n      connector: \"sqlite\",\n      options: { name: \"db\" }\n    },\n    users: {\n      connector: \"postgresql\",\n      options: {\n        url: \"postgresql://username:password@hostname:port/database_name\"\n      },\n    },\n  },\n});\n",[417,1188,1189,1201,1205,1215,1220,1225,1236,1247,1252,1257,1266,1271,1279,1284,1288,1293],{"__ignoreMap":5},[451,1190,1191,1193,1195,1197,1199],{"class":453,"line":454},[451,1192,458],{"class":457},[451,1194,462],{"class":461},[451,1196,465],{"class":457},[451,1198,469],{"class":468},[451,1200,472],{"class":461},[451,1202,1203],{"class":453,"line":475},[451,1204,479],{"emptyLinePlaceholder":478},[451,1206,1207,1209,1211,1213],{"class":453,"line":482},[451,1208,485],{"class":457},[451,1210,488],{"class":457},[451,1212,492],{"class":491},[451,1214,495],{"class":461},[451,1216,1217],{"class":453,"line":498},[451,1218,1219],{"class":461},"  database: {\n",[451,1221,1222],{"class":453,"line":504},[451,1223,1224],{"class":461},"    default: {\n",[451,1226,1227,1230,1233],{"class":453,"line":514},[451,1228,1229],{"class":461},"      connector: ",[451,1231,1232],{"class":468},"\"sqlite\"",[451,1234,1235],{"class":461},",\n",[451,1237,1238,1241,1244],{"class":453,"line":520},[451,1239,1240],{"class":461},"      options: { name: ",[451,1242,1243],{"class":468},"\"db\"",[451,1245,1246],{"class":461}," }\n",[451,1248,1249],{"class":453,"line":640},[451,1250,1251],{"class":461},"    },\n",[451,1253,1254],{"class":453,"line":657},[451,1255,1256],{"class":461},"    users: {\n",[451,1258,1259,1261,1264],{"class":453,"line":671},[451,1260,1229],{"class":461},[451,1262,1263],{"class":468},"\"postgresql\"",[451,1265,1235],{"class":461},[451,1267,1268],{"class":453,"line":676},[451,1269,1270],{"class":461},"      options: {\n",[451,1272,1273,1276],{"class":453,"line":682},[451,1274,1275],{"class":461},"        url: ",[451,1277,1278],{"class":468},"\"postgresql://username:password@hostname:port/database_name\"\n",[451,1280,1281],{"class":453,"line":718},[451,1282,1283],{"class":461},"      },\n",[451,1285,1286],{"class":453,"line":738},[451,1287,1251],{"class":461},[451,1289,1290],{"class":453,"line":743},[451,1291,1292],{"class":461},"  },\n",[451,1294,1295],{"class":453,"line":749},[451,1296,811],{"class":461},[813,1298,1300],{"id":1299},"development-database","Development Database",[400,1302,1303,1304,1307,1308,1311],{},"Use the ",[417,1305,1306],{},"devDatabase"," config to override the database configuration ",[404,1309,1310],{},"only for development mode",". This is useful for using a local SQLite database during development while targeting a different database in production.",[442,1313,1315],{"className":444,"code":1314,"filename":446,"language":447,"meta":5,"style":5},"import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  database: {\n    default: {\n      connector: \"postgresql\",\n      options: {\n        url: \"postgresql://username:password@hostname:port/database_name\"\n      }\n    }\n  },\n  devDatabase: {\n    default: {\n      connector: \"sqlite\",\n      options: { name: \"dev-db\" }\n    }\n  }\n});\n",[417,1316,1317,1329,1333,1343,1347,1351,1359,1363,1369,1374,1379,1383,1388,1392,1400,1409,1413,1417],{"__ignoreMap":5},[451,1318,1319,1321,1323,1325,1327],{"class":453,"line":454},[451,1320,458],{"class":457},[451,1322,462],{"class":461},[451,1324,465],{"class":457},[451,1326,469],{"class":468},[451,1328,472],{"class":461},[451,1330,1331],{"class":453,"line":475},[451,1332,479],{"emptyLinePlaceholder":478},[451,1334,1335,1337,1339,1341],{"class":453,"line":482},[451,1336,485],{"class":457},[451,1338,488],{"class":457},[451,1340,492],{"class":491},[451,1342,495],{"class":461},[451,1344,1345],{"class":453,"line":498},[451,1346,1219],{"class":461},[451,1348,1349],{"class":453,"line":504},[451,1350,1224],{"class":461},[451,1352,1353,1355,1357],{"class":453,"line":514},[451,1354,1229],{"class":461},[451,1356,1263],{"class":468},[451,1358,1235],{"class":461},[451,1360,1361],{"class":453,"line":520},[451,1362,1270],{"class":461},[451,1364,1365,1367],{"class":453,"line":640},[451,1366,1275],{"class":461},[451,1368,1278],{"class":468},[451,1370,1371],{"class":453,"line":657},[451,1372,1373],{"class":461},"      }\n",[451,1375,1376],{"class":453,"line":671},[451,1377,1378],{"class":461},"    }\n",[451,1380,1381],{"class":453,"line":676},[451,1382,1292],{"class":461},[451,1384,1385],{"class":453,"line":682},[451,1386,1387],{"class":461},"  devDatabase: {\n",[451,1389,1390],{"class":453,"line":718},[451,1391,1224],{"class":461},[451,1393,1394,1396,1398],{"class":453,"line":738},[451,1395,1229],{"class":461},[451,1397,1232],{"class":468},[451,1399,1235],{"class":461},[451,1401,1402,1404,1407],{"class":453,"line":743},[451,1403,1240],{"class":461},[451,1405,1406],{"class":468},"\"dev-db\"",[451,1408,1246],{"class":461},[451,1410,1411],{"class":453,"line":749},[451,1412,1378],{"class":461},[451,1414,1415],{"class":453,"line":783},[451,1416,517],{"class":461},[451,1418,1419],{"class":453,"line":788},[451,1420,811],{"class":461},[525,1422,1423],{},[400,1424,901,1425,1427,1428,1430,1431,1433],{},[417,1426,904],{}," is enabled and no ",[417,1429,1182],{}," or ",[417,1432,1306],{}," config is provided, Nitro automatically configures a default SQLite connection. In development mode, data is stored relative to the project root directory. In Node.js production, it uses the default SQLite path.",[545,1435,1437],{"id":1436},"connectors","Connectors",[400,1439,1440,1441,1446,1447,1450],{},"Nitro supports all ",[409,1442,1445],{"href":1443,"rel":1444},"https://db0.unjs.io/connectors",[413],"db0 connectors",". The ",[417,1448,1449],{},"connector"," field in the database config accepts any of the following values:",[1452,1453,1454,1467],"table",{},[1455,1456,1457],"thead",{},[1458,1459,1460,1464],"tr",{},[1461,1462,1463],"th",{},"Connector",[1461,1465,1466],{},"Description",[1468,1469,1470,1485,1494,1507,1520,1534,1552,1562,1572,1586,1600,1615,1630,1644,1654],"tbody",{},[1458,1471,1472,1478],{},[1473,1474,1475],"td",{},[417,1476,1477],{},"sqlite",[1473,1479,1480,1481,1484],{},"Node.js built-in SQLite (alias for ",[417,1482,1483],{},"node-sqlite",")",[1458,1486,1487,1491],{},[1473,1488,1489],{},[417,1490,1483],{},[1473,1492,1493],{},"Node.js built-in SQLite",[1458,1495,1496,1501],{},[1473,1497,1498],{},[417,1499,1500],{},"better-sqlite3",[1473,1502,1503],{},[409,1504,1500],{"href":1505,"rel":1506},"https://github.com/WiseLibs/better-sqlite3",[413],[1458,1508,1509,1514],{},[1473,1510,1511],{},[417,1512,1513],{},"sqlite3",[1473,1515,1516],{},[409,1517,1513],{"href":1518,"rel":1519},"https://github.com/TryGhost/node-sqlite3",[413],[1458,1521,1522,1531],{},[1473,1523,1524,1527,1528],{},[417,1525,1526],{},"bun"," / ",[417,1529,1530],{},"bun-sqlite",[1473,1532,1533],{},"Bun built-in SQLite",[1458,1535,1536,1544],{},[1473,1537,1538,1527,1541],{},[417,1539,1540],{},"libsql",[417,1542,1543],{},"libsql-node",[1473,1545,1546,1551],{},[409,1547,1550],{"href":1548,"rel":1549},"https://github.com/tursodatabase/libsql",[413],"libSQL"," (Node.js)",[1458,1553,1554,1559],{},[1473,1555,1556],{},[417,1557,1558],{},"libsql-http",[1473,1560,1561],{},"libSQL over HTTP",[1458,1563,1564,1569],{},[1473,1565,1566],{},[417,1567,1568],{},"libsql-web",[1473,1570,1571],{},"libSQL for web environments",[1458,1573,1574,1579],{},[1473,1575,1576],{},[417,1577,1578],{},"postgresql",[1473,1580,1581],{},[409,1582,1585],{"href":1583,"rel":1584},"https://github.com/porsager/postgres",[413],"PostgreSQL",[1458,1587,1588,1593],{},[1473,1589,1590],{},[417,1591,1592],{},"mysql2",[1473,1594,1595],{},[409,1596,1599],{"href":1597,"rel":1598},"https://github.com/sidorares/node-mysql2",[413],"MySQL",[1458,1601,1602,1607],{},[1473,1603,1604],{},[417,1605,1606],{},"pglite",[1473,1608,1609,1614],{},[409,1610,1613],{"href":1611,"rel":1612},"https://github.com/electric-sql/pglite",[413],"PGlite"," (embedded PostgreSQL)",[1458,1616,1617,1622],{},[1473,1618,1619],{},[417,1620,1621],{},"planetscale",[1473,1623,1624,1629],{},[409,1625,1628],{"href":1626,"rel":1627},"https://github.com/planetscale/database-js",[413],"PlanetScale"," serverless",[1458,1631,1632,1637],{},[1473,1633,1634],{},[417,1635,1636],{},"cloudflare-d1",[1473,1638,1639],{},[409,1640,1643],{"href":1641,"rel":1642},"https://developers.cloudflare.com/d1/",[413],"Cloudflare D1",[1458,1645,1646,1651],{},[1473,1647,1648],{},[417,1649,1650],{},"cloudflare-hyperdrive-mysql",[1473,1652,1653],{},"Cloudflare Hyperdrive with MySQL",[1458,1655,1656,1661],{},[1473,1657,1658],{},[417,1659,1660],{},"cloudflare-hyperdrive-postgresql",[1473,1662,1663],{},"Cloudflare Hyperdrive with PostgreSQL",[1665,1666,1667],"style",{},"html pre.shiki code .so5gQ, html code.shiki .so5gQ{--shiki-light:#D73A49;--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .slsVL, html code.shiki .slsVL{--shiki-light:#24292E;--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sfrk1, html code.shiki .sfrk1{--shiki-light:#032F62;--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}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 .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}",{"title":5,"searchDepth":475,"depth":475,"links":1669},[1670,1676,1679],{"id":547,"depth":475,"text":548,"children":1671},[1672,1673,1674,1675],{"id":815,"depth":482,"text":818},{"id":914,"depth":482,"text":917},{"id":1051,"depth":482,"text":1054},{"id":1097,"depth":482,"text":1100},{"id":1176,"depth":475,"text":33,"children":1677},[1678],{"id":1299,"depth":482,"text":1300},{"id":1436,"depth":475,"text":1437},"Nitro provides a built-in and lightweight SQL database layer.","md",{"automd":478,"icon":41},{"icon":41},{"title":38,"description":1680},"zqh7VPy_1ogZ39_0J66JNuS62v89b2H93BUjiGSGlIg",[1687,1689],{"title":33,"path":34,"stem":35,"description":1688,"icon":36,"children":-1},"Customize and extend Nitro defaults.",{"title":43,"path":44,"stem":45,"description":1690,"icon":46,"children":-1},"Understand how Nitro runs and serves incoming requests to your application.",1775834858591]