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