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