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