[{"data":1,"prerenderedAt":1690},["ShallowReactive",2],{"navigation":3,"-docs-database":394,"-docs-database-surround":1685},[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":1679,"extension":1680,"meta":1681,"navigation":1682,"path":39,"seo":1683,"stem":40,"__hash__":1684},"content/1.docs/50.database.md",{"type":397,"value":398,"toc":1667,"icon":41},"minimark",[399,421,426,438,441,524,534,544,549,811,818,828,895,908,911,917,920,1048,1054,1057,1094,1100,1103,1173,1176,1183,1296,1300,1311,1420,1433,1437,1450,1663],[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 { defineConfig } from \"nitro\";\n\nexport default defineConfig({\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"," { defineConfig } ",[451,464,465],{"class":457},"from",[451,467,469],{"class":468},"sfrk1"," \"nitro\"",[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"," defineConfig",[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,568,582,586,610,627,631,637,654,668,673,679,715,735,740,746,780,785,793,799,805],{"__ignoreMap":5},[451,556,557,559,562,564,566],{"class":453,"line":454},[451,558,458],{"class":457},[451,560,561],{"class":461}," { defineHandler } ",[451,563,465],{"class":457},[451,565,469],{"class":468},[451,567,472],{"class":461},[451,569,570,572,575,577,580],{"class":453,"line":475},[451,571,458],{"class":457},[451,573,574],{"class":461}," { useDatabase } ",[451,576,465],{"class":457},[451,578,579],{"class":468}," \"nitro/database\"",[451,581,472],{"class":461},[451,583,584],{"class":453,"line":482},[451,585,479],{"emptyLinePlaceholder":478},[451,587,588,590,592,595,598,601,604,607],{"class":453,"line":498},[451,589,485],{"class":457},[451,591,488],{"class":457},[451,593,594],{"class":491}," defineHandler",[451,596,597],{"class":461},"(",[451,599,600],{"class":457},"async",[451,602,603],{"class":461}," () ",[451,605,606],{"class":457},"=>",[451,608,609],{"class":461}," {\n",[451,611,612,615,618,621,624],{"class":453,"line":504},[451,613,614],{"class":457},"  const",[451,616,617],{"class":510}," db",[451,619,620],{"class":457}," =",[451,622,623],{"class":491}," useDatabase",[451,625,626],{"class":461},"();\n",[451,628,629],{"class":453,"line":514},[451,630,479],{"emptyLinePlaceholder":478},[451,632,633],{"class":453,"line":520},[451,634,636],{"class":635},"sCsY4","  // Create users table\n",[451,638,640,643,646,649,652],{"class":453,"line":639},8,[451,641,642],{"class":457},"  await",[451,644,645],{"class":461}," db.",[451,647,648],{"class":491},"sql",[451,650,651],{"class":468},"`DROP TABLE IF EXISTS users`",[451,653,472],{"class":461},[451,655,657,659,661,663,666],{"class":453,"line":656},9,[451,658,642],{"class":457},[451,660,645],{"class":461},[451,662,648],{"class":491},[451,664,665],{"class":468},"`CREATE TABLE IF NOT EXISTS users (\"id\" TEXT PRIMARY KEY, \"firstName\" TEXT, \"lastName\" TEXT, \"email\" TEXT)`",[451,667,472],{"class":461},[451,669,671],{"class":453,"line":670},10,[451,672,479],{"emptyLinePlaceholder":478},[451,674,676],{"class":453,"line":675},11,[451,677,678],{"class":635},"  // Add a new user\n",[451,680,682,684,687,689,692,695,698,700,703,706,709,712],{"class":453,"line":681},12,[451,683,614],{"class":457},[451,685,686],{"class":510}," userId",[451,688,620],{"class":457},[451,690,691],{"class":491}," String",[451,693,694],{"class":461},"(Math.",[451,696,697],{"class":491},"round",[451,699,694],{"class":461},[451,701,702],{"class":491},"random",[451,704,705],{"class":461},"() ",[451,707,708],{"class":457},"*",[451,710,711],{"class":510}," 10_000",[451,713,714],{"class":461},"));\n",[451,716,718,720,722,724,727,730,733],{"class":453,"line":717},13,[451,719,642],{"class":457},[451,721,645],{"class":461},[451,723,648],{"class":491},[451,725,726],{"class":468},"`INSERT INTO users VALUES (${",[451,728,729],{"class":461},"userId",[451,731,732],{"class":468},"}, 'John', 'Doe', '')`",[451,734,472],{"class":461},[451,736,738],{"class":453,"line":737},14,[451,739,479],{"emptyLinePlaceholder":478},[451,741,743],{"class":453,"line":742},15,[451,744,745],{"class":635},"  // Query for users\n",[451,747,749,751,754,757,760,763,766,768,770,773,775,778],{"class":453,"line":748},16,[451,750,614],{"class":457},[451,752,753],{"class":461}," { ",[451,755,756],{"class":510},"rows",[451,758,759],{"class":461}," } ",[451,761,762],{"class":457},"=",[451,764,765],{"class":457}," await",[451,767,645],{"class":461},[451,769,648],{"class":491},[451,771,772],{"class":468},"`SELECT * FROM users WHERE id = ${",[451,774,729],{"class":461},[451,776,777],{"class":468},"}`",[451,779,472],{"class":461},[451,781,783],{"class":453,"line":782},17,[451,784,479],{"emptyLinePlaceholder":478},[451,786,788,791],{"class":453,"line":787},18,[451,789,790],{"class":457},"  return",[451,792,609],{"class":461},[451,794,796],{"class":453,"line":795},19,[451,797,798],{"class":461},"    rows,\n",[451,800,802],{"class":453,"line":801},20,[451,803,804],{"class":461},"  };\n",[451,806,808],{"class":453,"line":807},21,[451,809,810],{"class":461},"});\n",[812,813,815],"h3",{"id":814},"usedatabase",[417,816,817],{},"useDatabase",[400,819,820,821,823,824,827],{},"Use ",[417,822,817],{}," to get a database instance. It accepts an optional connection name (defaults to ",[417,825,826],{},"\"default\"",").",[442,829,831],{"className":444,"code":830,"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,832,833,845,849,854,867,871,876],{"__ignoreMap":5},[451,834,835,837,839,841,843],{"class":453,"line":454},[451,836,458],{"class":457},[451,838,574],{"class":461},[451,840,465],{"class":457},[451,842,579],{"class":468},[451,844,472],{"class":461},[451,846,847],{"class":453,"line":475},[451,848,479],{"emptyLinePlaceholder":478},[451,850,851],{"class":453,"line":482},[451,852,853],{"class":635},"// Use the default connection\n",[451,855,856,859,861,863,865],{"class":453,"line":498},[451,857,858],{"class":457},"const",[451,860,617],{"class":510},[451,862,620],{"class":457},[451,864,623],{"class":491},[451,866,626],{"class":461},[451,868,869],{"class":453,"line":504},[451,870,479],{"emptyLinePlaceholder":478},[451,872,873],{"class":453,"line":514},[451,874,875],{"class":635},"// Use a named connection\n",[451,877,878,880,883,885,887,889,892],{"class":453,"line":520},[451,879,858],{"class":457},[451,881,882],{"class":510}," usersDb",[451,884,620],{"class":457},[451,886,623],{"class":491},[451,888,597],{"class":461},[451,890,891],{"class":468},"\"users\"",[451,893,894],{"class":461},");\n",[896,897,898],"note",{},[400,899,900,901,904,905,907],{},"\nWhen ",[417,902,903],{},"experimental.database"," is enabled, ",[417,906,817],{}," is auto-imported and available without an explicit import statement.",[400,909,910],{},"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.",[812,912,914],{"id":913},"dbsql",[417,915,916],{},"db.sql",[400,918,919],{},"Execute SQL queries using tagged template literals with automatic parameter binding:",[442,921,923],{"className":444,"code":922,"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,924,925,937,941,946,960,979,983,988,1014,1018,1023,1043],{"__ignoreMap":5},[451,926,927,929,931,933,935],{"class":453,"line":454},[451,928,858],{"class":457},[451,930,617],{"class":510},[451,932,620],{"class":457},[451,934,623],{"class":491},[451,936,626],{"class":461},[451,938,939],{"class":453,"line":475},[451,940,479],{"emptyLinePlaceholder":478},[451,942,943],{"class":453,"line":482},[451,944,945],{"class":635},"// Insert with parameterized values (safe from SQL injection)\n",[451,947,948,950,953,955,958],{"class":453,"line":498},[451,949,858],{"class":457},[451,951,952],{"class":510}," id",[451,954,620],{"class":457},[451,956,957],{"class":468}," \"1001\"",[451,959,472],{"class":461},[451,961,962,965,967,969,971,974,977],{"class":453,"line":504},[451,963,964],{"class":457},"await",[451,966,645],{"class":461},[451,968,648],{"class":491},[451,970,726],{"class":468},[451,972,973],{"class":461},"id",[451,975,976],{"class":468},"}, 'John', 'Doe', 'john@example.com')`",[451,978,472],{"class":461},[451,980,981],{"class":453,"line":514},[451,982,479],{"emptyLinePlaceholder":478},[451,984,985],{"class":453,"line":520},[451,986,987],{"class":635},"// Query with parameters\n",[451,989,990,992,994,996,998,1000,1002,1004,1006,1008,1010,1012],{"class":453,"line":639},[451,991,858],{"class":457},[451,993,753],{"class":461},[451,995,756],{"class":510},[451,997,759],{"class":461},[451,999,762],{"class":457},[451,1001,765],{"class":457},[451,1003,645],{"class":461},[451,1005,648],{"class":491},[451,1007,772],{"class":468},[451,1009,973],{"class":461},[451,1011,777],{"class":468},[451,1013,472],{"class":461},[451,1015,1016],{"class":453,"line":656},[451,1017,479],{"emptyLinePlaceholder":478},[451,1019,1020],{"class":453,"line":670},[451,1021,1022],{"class":635},"// The result includes rows, changes count, and last insert ID\n",[451,1024,1025,1027,1030,1032,1034,1036,1038,1041],{"class":453,"line":675},[451,1026,858],{"class":457},[451,1028,1029],{"class":510}," result",[451,1031,620],{"class":457},[451,1033,765],{"class":457},[451,1035,645],{"class":461},[451,1037,648],{"class":491},[451,1039,1040],{"class":468},"`INSERT INTO posts (title) VALUES (${\"Hello\"})`",[451,1042,472],{"class":461},[451,1044,1045],{"class":453,"line":681},[451,1046,1047],{"class":635},"// result.rows, result.changes, result.lastInsertRowid\n",[812,1049,1051],{"id":1050},"dbexec",[417,1052,1053],{},"db.exec",[400,1055,1056],{},"Execute a raw SQL string directly:",[442,1058,1060],{"className":444,"code":1059,"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,1061,1062,1074,1078],{"__ignoreMap":5},[451,1063,1064,1066,1068,1070,1072],{"class":453,"line":454},[451,1065,858],{"class":457},[451,1067,617],{"class":510},[451,1069,620],{"class":457},[451,1071,623],{"class":491},[451,1073,626],{"class":461},[451,1075,1076],{"class":453,"line":475},[451,1077,479],{"emptyLinePlaceholder":478},[451,1079,1080,1082,1084,1087,1089,1092],{"class":453,"line":482},[451,1081,964],{"class":457},[451,1083,645],{"class":461},[451,1085,1086],{"class":491},"exec",[451,1088,597],{"class":461},[451,1090,1091],{"class":468},"\"CREATE TABLE IF NOT EXISTS users (id TEXT PRIMARY KEY, name TEXT)\"",[451,1093,894],{"class":461},[812,1095,1097],{"id":1096},"dbprepare",[417,1098,1099],{},"db.prepare",[400,1101,1102],{},"Prepare an SQL statement for repeated execution:",[442,1104,1106],{"className":444,"code":1105,"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,1107,1108,1120,1124,1145],{"__ignoreMap":5},[451,1109,1110,1112,1114,1116,1118],{"class":453,"line":454},[451,1111,858],{"class":457},[451,1113,617],{"class":510},[451,1115,620],{"class":457},[451,1117,623],{"class":491},[451,1119,626],{"class":461},[451,1121,1122],{"class":453,"line":475},[451,1123,479],{"emptyLinePlaceholder":478},[451,1125,1126,1128,1131,1133,1135,1138,1140,1143],{"class":453,"line":482},[451,1127,858],{"class":457},[451,1129,1130],{"class":510}," stmt",[451,1132,620],{"class":457},[451,1134,645],{"class":461},[451,1136,1137],{"class":491},"prepare",[451,1139,597],{"class":461},[451,1141,1142],{"class":468},"\"SELECT * FROM users WHERE id = ?\"",[451,1144,894],{"class":461},[451,1146,1147,1149,1151,1153,1155,1158,1161,1163,1166,1168,1171],{"class":453,"line":498},[451,1148,858],{"class":457},[451,1150,1029],{"class":510},[451,1152,620],{"class":457},[451,1154,765],{"class":457},[451,1156,1157],{"class":461}," stmt.",[451,1159,1160],{"class":491},"bind",[451,1162,597],{"class":461},[451,1164,1165],{"class":468},"\"1001\"",[451,1167,827],{"class":461},[451,1169,1170],{"class":491},"all",[451,1172,626],{"class":461},[545,1174,33],{"id":1175},"configuration",[400,1177,1178,1179,1182],{},"You can configure database connections using ",[417,1180,1181],{},"database"," config:",[442,1184,1186],{"className":444,"code":1185,"filename":446,"language":447,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\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,1187,1188,1200,1204,1214,1219,1224,1235,1246,1251,1256,1265,1270,1278,1283,1287,1292],{"__ignoreMap":5},[451,1189,1190,1192,1194,1196,1198],{"class":453,"line":454},[451,1191,458],{"class":457},[451,1193,462],{"class":461},[451,1195,465],{"class":457},[451,1197,469],{"class":468},[451,1199,472],{"class":461},[451,1201,1202],{"class":453,"line":475},[451,1203,479],{"emptyLinePlaceholder":478},[451,1205,1206,1208,1210,1212],{"class":453,"line":482},[451,1207,485],{"class":457},[451,1209,488],{"class":457},[451,1211,492],{"class":491},[451,1213,495],{"class":461},[451,1215,1216],{"class":453,"line":498},[451,1217,1218],{"class":461},"  database: {\n",[451,1220,1221],{"class":453,"line":504},[451,1222,1223],{"class":461},"    default: {\n",[451,1225,1226,1229,1232],{"class":453,"line":514},[451,1227,1228],{"class":461},"      connector: ",[451,1230,1231],{"class":468},"\"sqlite\"",[451,1233,1234],{"class":461},",\n",[451,1236,1237,1240,1243],{"class":453,"line":520},[451,1238,1239],{"class":461},"      options: { name: ",[451,1241,1242],{"class":468},"\"db\"",[451,1244,1245],{"class":461}," }\n",[451,1247,1248],{"class":453,"line":639},[451,1249,1250],{"class":461},"    },\n",[451,1252,1253],{"class":453,"line":656},[451,1254,1255],{"class":461},"    users: {\n",[451,1257,1258,1260,1263],{"class":453,"line":670},[451,1259,1228],{"class":461},[451,1261,1262],{"class":468},"\"postgresql\"",[451,1264,1234],{"class":461},[451,1266,1267],{"class":453,"line":675},[451,1268,1269],{"class":461},"      options: {\n",[451,1271,1272,1275],{"class":453,"line":681},[451,1273,1274],{"class":461},"        url: ",[451,1276,1277],{"class":468},"\"postgresql://username:password@hostname:port/database_name\"\n",[451,1279,1280],{"class":453,"line":717},[451,1281,1282],{"class":461},"      },\n",[451,1284,1285],{"class":453,"line":737},[451,1286,1250],{"class":461},[451,1288,1289],{"class":453,"line":742},[451,1290,1291],{"class":461},"  },\n",[451,1293,1294],{"class":453,"line":748},[451,1295,810],{"class":461},[812,1297,1299],{"id":1298},"development-database","Development Database",[400,1301,1302,1303,1306,1307,1310],{},"Use the ",[417,1304,1305],{},"devDatabase"," config to override the database configuration ",[404,1308,1309],{},"only for development mode",". This is useful for using a local SQLite database during development while targeting a different database in production.",[442,1312,1314],{"className":444,"code":1313,"filename":446,"language":447,"meta":5,"style":5},"import { defineConfig } from \"nitro\";\n\nexport default defineConfig({\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,1315,1316,1328,1332,1342,1346,1350,1358,1362,1368,1373,1378,1382,1387,1391,1399,1408,1412,1416],{"__ignoreMap":5},[451,1317,1318,1320,1322,1324,1326],{"class":453,"line":454},[451,1319,458],{"class":457},[451,1321,462],{"class":461},[451,1323,465],{"class":457},[451,1325,469],{"class":468},[451,1327,472],{"class":461},[451,1329,1330],{"class":453,"line":475},[451,1331,479],{"emptyLinePlaceholder":478},[451,1333,1334,1336,1338,1340],{"class":453,"line":482},[451,1335,485],{"class":457},[451,1337,488],{"class":457},[451,1339,492],{"class":491},[451,1341,495],{"class":461},[451,1343,1344],{"class":453,"line":498},[451,1345,1218],{"class":461},[451,1347,1348],{"class":453,"line":504},[451,1349,1223],{"class":461},[451,1351,1352,1354,1356],{"class":453,"line":514},[451,1353,1228],{"class":461},[451,1355,1262],{"class":468},[451,1357,1234],{"class":461},[451,1359,1360],{"class":453,"line":520},[451,1361,1269],{"class":461},[451,1363,1364,1366],{"class":453,"line":639},[451,1365,1274],{"class":461},[451,1367,1277],{"class":468},[451,1369,1370],{"class":453,"line":656},[451,1371,1372],{"class":461},"      }\n",[451,1374,1375],{"class":453,"line":670},[451,1376,1377],{"class":461},"    }\n",[451,1379,1380],{"class":453,"line":675},[451,1381,1291],{"class":461},[451,1383,1384],{"class":453,"line":681},[451,1385,1386],{"class":461},"  devDatabase: {\n",[451,1388,1389],{"class":453,"line":717},[451,1390,1223],{"class":461},[451,1392,1393,1395,1397],{"class":453,"line":737},[451,1394,1228],{"class":461},[451,1396,1231],{"class":468},[451,1398,1234],{"class":461},[451,1400,1401,1403,1406],{"class":453,"line":742},[451,1402,1239],{"class":461},[451,1404,1405],{"class":468},"\"dev-db\"",[451,1407,1245],{"class":461},[451,1409,1410],{"class":453,"line":748},[451,1411,1377],{"class":461},[451,1413,1414],{"class":453,"line":782},[451,1415,517],{"class":461},[451,1417,1418],{"class":453,"line":787},[451,1419,810],{"class":461},[525,1421,1422],{},[400,1423,900,1424,1426,1427,1429,1430,1432],{},[417,1425,903],{}," is enabled and no ",[417,1428,1181],{}," or ",[417,1431,1305],{}," 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,1434,1436],{"id":1435},"connectors","Connectors",[400,1438,1439,1440,1445,1446,1449],{},"Nitro supports all ",[409,1441,1444],{"href":1442,"rel":1443},"https://db0.unjs.io/connectors",[413],"db0 connectors",". The ",[417,1447,1448],{},"connector"," field in the database config accepts any of the following values:",[1451,1452,1453,1466],"table",{},[1454,1455,1456],"thead",{},[1457,1458,1459,1463],"tr",{},[1460,1461,1462],"th",{},"Connector",[1460,1464,1465],{},"Description",[1467,1468,1469,1484,1493,1506,1519,1533,1551,1561,1571,1585,1599,1614,1629,1643,1653],"tbody",{},[1457,1470,1471,1477],{},[1472,1473,1474],"td",{},[417,1475,1476],{},"sqlite",[1472,1478,1479,1480,1483],{},"Node.js built-in SQLite (alias for ",[417,1481,1482],{},"node-sqlite",")",[1457,1485,1486,1490],{},[1472,1487,1488],{},[417,1489,1482],{},[1472,1491,1492],{},"Node.js built-in SQLite",[1457,1494,1495,1500],{},[1472,1496,1497],{},[417,1498,1499],{},"better-sqlite3",[1472,1501,1502],{},[409,1503,1499],{"href":1504,"rel":1505},"https://github.com/WiseLibs/better-sqlite3",[413],[1457,1507,1508,1513],{},[1472,1509,1510],{},[417,1511,1512],{},"sqlite3",[1472,1514,1515],{},[409,1516,1512],{"href":1517,"rel":1518},"https://github.com/TryGhost/node-sqlite3",[413],[1457,1520,1521,1530],{},[1472,1522,1523,1526,1527],{},[417,1524,1525],{},"bun"," / ",[417,1528,1529],{},"bun-sqlite",[1472,1531,1532],{},"Bun built-in SQLite",[1457,1534,1535,1543],{},[1472,1536,1537,1526,1540],{},[417,1538,1539],{},"libsql",[417,1541,1542],{},"libsql-node",[1472,1544,1545,1550],{},[409,1546,1549],{"href":1547,"rel":1548},"https://github.com/tursodatabase/libsql",[413],"libSQL"," (Node.js)",[1457,1552,1553,1558],{},[1472,1554,1555],{},[417,1556,1557],{},"libsql-http",[1472,1559,1560],{},"libSQL over HTTP",[1457,1562,1563,1568],{},[1472,1564,1565],{},[417,1566,1567],{},"libsql-web",[1472,1569,1570],{},"libSQL for web environments",[1457,1572,1573,1578],{},[1472,1574,1575],{},[417,1576,1577],{},"postgresql",[1472,1579,1580],{},[409,1581,1584],{"href":1582,"rel":1583},"https://github.com/porsager/postgres",[413],"PostgreSQL",[1457,1586,1587,1592],{},[1472,1588,1589],{},[417,1590,1591],{},"mysql2",[1472,1593,1594],{},[409,1595,1598],{"href":1596,"rel":1597},"https://github.com/sidorares/node-mysql2",[413],"MySQL",[1457,1600,1601,1606],{},[1472,1602,1603],{},[417,1604,1605],{},"pglite",[1472,1607,1608,1613],{},[409,1609,1612],{"href":1610,"rel":1611},"https://github.com/electric-sql/pglite",[413],"PGlite"," (embedded PostgreSQL)",[1457,1615,1616,1621],{},[1472,1617,1618],{},[417,1619,1620],{},"planetscale",[1472,1622,1623,1628],{},[409,1624,1627],{"href":1625,"rel":1626},"https://github.com/planetscale/database-js",[413],"PlanetScale"," serverless",[1457,1630,1631,1636],{},[1472,1632,1633],{},[417,1634,1635],{},"cloudflare-d1",[1472,1637,1638],{},[409,1639,1642],{"href":1640,"rel":1641},"https://developers.cloudflare.com/d1/",[413],"Cloudflare D1",[1457,1644,1645,1650],{},[1472,1646,1647],{},[417,1648,1649],{},"cloudflare-hyperdrive-mysql",[1472,1651,1652],{},"Cloudflare Hyperdrive with MySQL",[1457,1654,1655,1660],{},[1472,1656,1657],{},[417,1658,1659],{},"cloudflare-hyperdrive-postgresql",[1472,1661,1662],{},"Cloudflare Hyperdrive with PostgreSQL",[1664,1665,1666],"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":1668},[1669,1675,1678],{"id":547,"depth":475,"text":548,"children":1670},[1671,1672,1673,1674],{"id":814,"depth":482,"text":817},{"id":913,"depth":482,"text":916},{"id":1050,"depth":482,"text":1053},{"id":1096,"depth":482,"text":1099},{"id":1175,"depth":475,"text":33,"children":1676},[1677],{"id":1298,"depth":482,"text":1299},{"id":1435,"depth":475,"text":1436},"Nitro provides a built-in and lightweight SQL database layer.","md",{"automd":478,"icon":41},{"icon":41},{"title":38,"description":1679},"CXKtH1yGSP222fQegEMCxW-2MDrXivO-KXCZD6ReIEc",[1686,1688],{"title":33,"path":34,"stem":35,"description":1687,"icon":36,"children":-1},"Customize and extend Nitro defaults.",{"title":43,"path":44,"stem":45,"description":1689,"icon":46,"children":-1},"Understand how Nitro runs and serves incoming requests to your application.",1776075610853]