[{"data":1,"prerenderedAt":803},["ShallowReactive",2],{"navigation":3,"-docs-database":228,"-docs-database-surround":798},[4,83,212,218,225],{"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],{"title":219,"path":220,"stem":221,"icon":224},"i-lucide-folder-code",{"title":5,"path":226,"stem":227},"/","index",{"id":229,"title":38,"body":230,"description":792,"extension":793,"meta":794,"navigation":795,"path":39,"seo":796,"stem":40,"__hash__":797},"content/1.docs/50.database.md",{"type":231,"value":232,"toc":788,"icon":41},"minimark",[233,240,261,266,278,281,364,374,384,389,652,655,662,775,784],[234,235,236],"warning",{},[237,238,239],"p",{},"Nitro v3 Alpha docs are a work in progress — expect updates, rough edges, and occasional inaccuracies.",[237,241,242,243,247,248,255,256,260],{},"The default database connection is ",[244,245,246],"strong",{},"preconfigured"," with ",[249,250,254],"a",{"href":251,"rel":252},"https://db0.unjs.io/connectors/sqlite",[253],"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 ",[257,258,259],"code",{},".data/db.sqlite",".",[262,263],"read-more",{"title":264,"to":265},"DB0 Documentation","https://db0.unjs.io",[267,268,269],"important",{},[237,270,271,272,277],{},"\nDatabase support is currently experimental.\nRefer to the ",[249,273,276],{"href":274,"rel":275},"https://github.com/unjs/db0/issues",[253],"db0 issues"," for status and bug report.",[237,279,280],{},"In order to enable database layer you need to enable experimental feature flag.",[282,283,288],"pre",{"className":284,"code":285,"filename":286,"language":287,"meta":5,"style":5},"language-ts shiki shiki-themes github-light github-dark github-dark","import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  experimental: {\n    database: true\n  }\n})\n","nitro.config.ts","ts",[257,289,290,313,320,336,342,352,358],{"__ignoreMap":5},[291,292,295,299,303,306,310],"span",{"class":293,"line":294},"line",1,[291,296,298],{"class":297},"so5gQ","import",[291,300,302],{"class":301},"slsVL"," { defineNitroConfig } ",[291,304,305],{"class":297},"from",[291,307,309],{"class":308},"sfrk1"," \"nitro/config\"",[291,311,312],{"class":301},";\n",[291,314,316],{"class":293,"line":315},2,[291,317,319],{"emptyLinePlaceholder":318},true,"\n",[291,321,323,326,329,333],{"class":293,"line":322},3,[291,324,325],{"class":297},"export",[291,327,328],{"class":297}," default",[291,330,332],{"class":331},"shcOC"," defineNitroConfig",[291,334,335],{"class":301},"({\n",[291,337,339],{"class":293,"line":338},4,[291,340,341],{"class":301},"  experimental: {\n",[291,343,345,348],{"class":293,"line":344},5,[291,346,347],{"class":301},"    database: ",[291,349,351],{"class":350},"suiK_","true\n",[291,353,355],{"class":293,"line":354},6,[291,356,357],{"class":301},"  }\n",[291,359,361],{"class":293,"line":360},7,[291,362,363],{"class":301},"})\n",[365,366,367],"tip",{},[237,368,369,370,260],{},"\nYou can change default connection or define more connections to any of the ",[249,371,373],{"href":251,"rel":372},[253],"supported databases",[365,375,376],{},[237,377,378,379,260],{},"\nYou can integrate database instance to any of the ",[249,380,383],{"href":381,"rel":382},"https://db0.unjs.io/integrations",[253],"supported ORMs",[385,386,388],"h2",{"id":387},"usage","Usage",[282,390,393],{"className":284,"code":391,"filename":392,"language":287,"meta":5,"style":5},"import { defineHandler } from \"nitro/h3\";\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",[257,394,395,409,423,427,451,468,472,478,495,509,514,520,556,576,581,587,621,626,634,640,646],{"__ignoreMap":5},[291,396,397,399,402,404,407],{"class":293,"line":294},[291,398,298],{"class":297},[291,400,401],{"class":301}," { defineHandler } ",[291,403,305],{"class":297},[291,405,406],{"class":308}," \"nitro/h3\"",[291,408,312],{"class":301},[291,410,411,413,416,418,421],{"class":293,"line":315},[291,412,298],{"class":297},[291,414,415],{"class":301}," { useDatabase } ",[291,417,305],{"class":297},[291,419,420],{"class":308}," \"nitro/database\"",[291,422,312],{"class":301},[291,424,425],{"class":293,"line":322},[291,426,319],{"emptyLinePlaceholder":318},[291,428,429,431,433,436,439,442,445,448],{"class":293,"line":338},[291,430,325],{"class":297},[291,432,328],{"class":297},[291,434,435],{"class":331}," defineHandler",[291,437,438],{"class":301},"(",[291,440,441],{"class":297},"async",[291,443,444],{"class":301}," () ",[291,446,447],{"class":297},"=>",[291,449,450],{"class":301}," {\n",[291,452,453,456,459,462,465],{"class":293,"line":344},[291,454,455],{"class":297},"  const",[291,457,458],{"class":350}," db",[291,460,461],{"class":297}," =",[291,463,464],{"class":331}," useDatabase",[291,466,467],{"class":301},"();\n",[291,469,470],{"class":293,"line":354},[291,471,319],{"emptyLinePlaceholder":318},[291,473,474],{"class":293,"line":360},[291,475,477],{"class":476},"sCsY4","  // Create users table\n",[291,479,481,484,487,490,493],{"class":293,"line":480},8,[291,482,483],{"class":297},"  await",[291,485,486],{"class":301}," db.",[291,488,489],{"class":331},"sql",[291,491,492],{"class":308},"`DROP TABLE IF EXISTS users`",[291,494,312],{"class":301},[291,496,498,500,502,504,507],{"class":293,"line":497},9,[291,499,483],{"class":297},[291,501,486],{"class":301},[291,503,489],{"class":331},[291,505,506],{"class":308},"`CREATE TABLE IF NOT EXISTS users (\"id\" TEXT PRIMARY KEY, \"firstName\" TEXT, \"lastName\" TEXT, \"email\" TEXT)`",[291,508,312],{"class":301},[291,510,512],{"class":293,"line":511},10,[291,513,319],{"emptyLinePlaceholder":318},[291,515,517],{"class":293,"line":516},11,[291,518,519],{"class":476},"  // Add a new user\n",[291,521,523,525,528,530,533,536,539,541,544,547,550,553],{"class":293,"line":522},12,[291,524,455],{"class":297},[291,526,527],{"class":350}," userId",[291,529,461],{"class":297},[291,531,532],{"class":331}," String",[291,534,535],{"class":301},"(Math.",[291,537,538],{"class":331},"round",[291,540,535],{"class":301},[291,542,543],{"class":331},"random",[291,545,546],{"class":301},"() ",[291,548,549],{"class":297},"*",[291,551,552],{"class":350}," 10_000",[291,554,555],{"class":301},"));\n",[291,557,559,561,563,565,568,571,574],{"class":293,"line":558},13,[291,560,483],{"class":297},[291,562,486],{"class":301},[291,564,489],{"class":331},[291,566,567],{"class":308},"`INSERT INTO users VALUES (${",[291,569,570],{"class":301},"userId",[291,572,573],{"class":308},"}, 'John', 'Doe', '')`",[291,575,312],{"class":301},[291,577,579],{"class":293,"line":578},14,[291,580,319],{"emptyLinePlaceholder":318},[291,582,584],{"class":293,"line":583},15,[291,585,586],{"class":476},"  // Query for users\n",[291,588,590,592,595,598,601,604,607,609,611,614,616,619],{"class":293,"line":589},16,[291,591,455],{"class":297},[291,593,594],{"class":301}," { ",[291,596,597],{"class":350},"rows",[291,599,600],{"class":301}," } ",[291,602,603],{"class":297},"=",[291,605,606],{"class":297}," await",[291,608,486],{"class":301},[291,610,489],{"class":331},[291,612,613],{"class":308},"`SELECT * FROM users WHERE id = ${",[291,615,570],{"class":301},[291,617,618],{"class":308},"}`",[291,620,312],{"class":301},[291,622,624],{"class":293,"line":623},17,[291,625,319],{"emptyLinePlaceholder":318},[291,627,629,632],{"class":293,"line":628},18,[291,630,631],{"class":297},"  return",[291,633,450],{"class":301},[291,635,637],{"class":293,"line":636},19,[291,638,639],{"class":301},"    rows,\n",[291,641,643],{"class":293,"line":642},20,[291,644,645],{"class":301},"  };\n",[291,647,649],{"class":293,"line":648},21,[291,650,651],{"class":301},"});\n",[385,653,33],{"id":654},"configuration",[237,656,657,658,661],{},"You can configure database connections using ",[257,659,660],{},"database"," config:",[282,663,665],{"className":284,"code":664,"filename":286,"language":287,"meta":5,"style":5},"import { defineNitroConfig } from \"nitro/config\";\n\nexport default defineNitroConfig({\n  database: {\n    default: {\n      connector: \"sqlite\",\n      options: { name: \"db\" }\n    },\n    users: {\n      connector: \"postgresql\",\n      options: {\n        url: \"postgresql://username:password@hostname:port/database_name\"\n      },\n    },\n  },\n});\n",[257,666,667,679,683,693,698,703,714,725,730,735,744,749,757,762,766,771],{"__ignoreMap":5},[291,668,669,671,673,675,677],{"class":293,"line":294},[291,670,298],{"class":297},[291,672,302],{"class":301},[291,674,305],{"class":297},[291,676,309],{"class":308},[291,678,312],{"class":301},[291,680,681],{"class":293,"line":315},[291,682,319],{"emptyLinePlaceholder":318},[291,684,685,687,689,691],{"class":293,"line":322},[291,686,325],{"class":297},[291,688,328],{"class":297},[291,690,332],{"class":331},[291,692,335],{"class":301},[291,694,695],{"class":293,"line":338},[291,696,697],{"class":301},"  database: {\n",[291,699,700],{"class":293,"line":344},[291,701,702],{"class":301},"    default: {\n",[291,704,705,708,711],{"class":293,"line":354},[291,706,707],{"class":301},"      connector: ",[291,709,710],{"class":308},"\"sqlite\"",[291,712,713],{"class":301},",\n",[291,715,716,719,722],{"class":293,"line":360},[291,717,718],{"class":301},"      options: { name: ",[291,720,721],{"class":308},"\"db\"",[291,723,724],{"class":301}," }\n",[291,726,727],{"class":293,"line":480},[291,728,729],{"class":301},"    },\n",[291,731,732],{"class":293,"line":497},[291,733,734],{"class":301},"    users: {\n",[291,736,737,739,742],{"class":293,"line":511},[291,738,707],{"class":301},[291,740,741],{"class":308},"\"postgresql\"",[291,743,713],{"class":301},[291,745,746],{"class":293,"line":516},[291,747,748],{"class":301},"      options: {\n",[291,750,751,754],{"class":293,"line":522},[291,752,753],{"class":301},"        url: ",[291,755,756],{"class":308},"\"postgresql://username:password@hostname:port/database_name\"\n",[291,758,759],{"class":293,"line":558},[291,760,761],{"class":301},"      },\n",[291,763,764],{"class":293,"line":578},[291,765,729],{"class":301},[291,767,768],{"class":293,"line":583},[291,769,770],{"class":301},"  },\n",[291,772,773],{"class":293,"line":589},[291,774,651],{"class":301},[365,776,777],{},[237,778,779,780,783],{},"\nYou can use the ",[257,781,782],{},"devDatabase","  config to overwrite the database configuration only for development mode.",[785,786,787],"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":315,"depth":315,"links":789},[790,791],{"id":387,"depth":315,"text":388},{"id":654,"depth":315,"text":33},"Nitro provides a built-in and lightweight SQL database layer.","md",{"automd":318,"icon":41},{"icon":41},{"title":38,"description":792},"N2VWl8KtT02LsaVsH-o1MhFjIKjgv2wfG8e6_Sk-luc",[799,801],{"title":33,"path":34,"stem":35,"description":800,"icon":36,"children":-1},"Customize and extend Nitro defaults.",{"title":43,"path":44,"stem":45,"description":802,"icon":46,"children":-1},"Understand how Nitro runs and serves incoming requests to your application.",1773176970098]