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