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