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