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