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