[{"data":1,"prerenderedAt":528},["ShallowReactive",2],{"navigation":3,"-guide":104,"-guide-surround":524},[4,21,82],{"title":5,"path":6,"stem":7,"children":8,"icon":10},"Getting Started","/guide","1.guide/1.index",[9,11,16],{"title":5,"path":6,"stem":7,"icon":10},"ph:book-open-duotone",{"title":12,"path":13,"stem":14,"icon":15},"HTTP Server","/guide/http-server","1.guide/3.http-server","material-symbols:http",{"title":17,"path":18,"stem":19,"icon":20},"Custom Connectors","/guide/custom-connector","1.guide/4.custom-connector","material-symbols-light:dashboard-customize",{"title":22,"path":23,"stem":24,"children":25,"icon":27},"Connectors","/connectors","2.connectors/1.index",[26,28,33,38,43,48,53,58,63,67,72,77],{"title":22,"path":23,"stem":24,"icon":27},"gravity-ui:plug-connection",{"title":29,"path":30,"stem":31,"icon":32},"Bun SQlite","/connectors/bun","2.connectors/bun","simple-icons:bun",{"title":34,"path":35,"stem":36,"icon":37},"Cloudflare","/connectors/cloudflare","2.connectors/cloudflare","devicon-plain:cloudflareworkers",{"title":39,"path":40,"stem":41,"icon":42},"LibSQL","/connectors/libsql","2.connectors/libsql","clarity:node-line",{"title":44,"path":45,"stem":46,"icon":47},"MySQL","/connectors/mysql","2.connectors/mysql","simple-icons:mysql",{"title":49,"path":50,"stem":51,"icon":52},"NEON","/connectors/neon","2.connectors/neon","cbi:neon",{"title":54,"path":55,"stem":56,"icon":57},"PGlite","/connectors/pglite","2.connectors/pglite","simple-icons:postgresql",{"title":59,"path":60,"stem":61,"icon":62},"PlanetScale","/connectors/planetscale","2.connectors/planetscale","simple-icons:planetscale",{"title":64,"path":65,"stem":66,"icon":57},"PostgreSQL","/connectors/postgresql","2.connectors/postgresql",{"title":68,"path":69,"stem":70,"icon":71},"SQLite","/connectors/sqlite","2.connectors/sqlite","simple-icons:sqlite",{"title":73,"path":74,"stem":75,"icon":76},"Turso","/connectors/turso","2.connectors/turso","simple-icons:turso",{"title":78,"path":79,"stem":80,"icon":81},"Vercel","/connectors/vercel","2.connectors/vercel","radix-icons:vercel-logo",{"title":83,"path":84,"stem":85,"children":86,"icon":88},"Integrations","/integrations","3.integrations/1.index",[87,89,94,99],{"title":83,"path":84,"stem":85,"icon":88},"carbon:property-relationship",{"title":90,"path":91,"stem":92,"icon":93},"Drizzle","/integrations/drizzle","3.integrations/drizzle","simple-icons:drizzle",{"title":95,"path":96,"stem":97,"icon":98},"Kysely","/integrations/kysely","3.integrations/kysely","mynaui:letter-k",{"title":100,"path":101,"stem":102,"icon":103},"Prisma","/integrations/prisma","3.integrations/prisma","simple-icons:prisma",{"id":105,"title":5,"body":106,"description":518,"extension":519,"meta":520,"navigation":521,"path":6,"seo":522,"stem":7,"__hash__":523},"content/1.guide/1.index.md",{"type":107,"value":108,"toc":514,"icon":10},"minimark",[109,124,127,133,140,143,148,160,163,484,501,505,508,510],[110,111,112],"important",{},[113,114,115,116,123],"p",{},"\nDB0 development is in the early stages. Follow up progress via ",[117,118,122],"a",{"href":119,"rel":120},"https://github.com/unjs/db0/issues",[121],"nofollow","GitHub issues",".",[113,125,126],{},"DB0 is a lightweight SQL connector:",[113,128,129,130,123],{},"✅ Works with several SQL ",[117,131,132],{"href":23},"connectors",[113,134,135,136,139],{},"✅ Can be ",[117,137,138],{"href":84},"integrated"," with ORMs and embedded into frameworks.",[113,141,142],{},"✅ Provides a simple but elegant query API out of the box.",[144,145,147],"h2",{"id":146},"quick-start","Quick start",[113,149,150,151,159],{},"Install ",[117,152,155],{"href":153,"rel":154},"https://npmjs.com/package/db0",[121],[156,157,158],"code",{},"db0"," npm package:",[161,162],"pm-install",{"name":158},[164,165,170],"pre",{"className":166,"code":167,"language":168,"meta":169,"style":169},"language-ts shiki shiki-themes github-light github-dark github-dark","import { createDatabase } from \"db0\";\nimport sqlite from \"db0/connectors/better-sqlite3\";\n\n// Initiate database with SQLite connector\nconst db = createDatabase(sqlite({}));\n\n// Alternative:\n// `using` automatically closes the database connection\n// once the `db` variable goes out of scope  (for example, the function execution ends)\n// await using db = createDatabase(sqlite({}));\n\n// Create users table\nawait db.sql`CREATE TABLE IF NOT EXISTS users (\"id\" TEXT PRIMARY KEY, \"firstName\" TEXT, \"lastName\" TEXT, \"email\" TEXT)`;\n\n// Add a new user\nconst userId = \"1001\";\nawait db.sql`INSERT INTO users VALUES (${userId}, 'John', 'Doe', '')`;\n\n// Query for users\nconst { rows } = await db.sql`SELECT * FROM users WHERE id = ${userId}`;\nconsole.log(rows);\n\n// Using static parameters\nconst tableName = \"users\";\nconst { rows } =\n  await db.sql`SELECT * FROM {${tableName}} WHERE id = ${userId}`;\nconsole.log(rows);\n","ts","",[156,171,172,195,210,217,224,250,255,261,267,273,279,284,290,307,312,318,333,353,358,364,398,410,415,421,436,450,475],{"__ignoreMap":169},[173,174,177,181,185,188,192],"span",{"class":175,"line":176},"line",1,[173,178,180],{"class":179},"so5gQ","import",[173,182,184],{"class":183},"slsVL"," { createDatabase } ",[173,186,187],{"class":179},"from",[173,189,191],{"class":190},"sfrk1"," \"db0\"",[173,193,194],{"class":183},";\n",[173,196,198,200,203,205,208],{"class":175,"line":197},2,[173,199,180],{"class":179},[173,201,202],{"class":183}," sqlite ",[173,204,187],{"class":179},[173,206,207],{"class":190}," \"db0/connectors/better-sqlite3\"",[173,209,194],{"class":183},[173,211,213],{"class":175,"line":212},3,[173,214,216],{"emptyLinePlaceholder":215},true,"\n",[173,218,220],{"class":175,"line":219},4,[173,221,223],{"class":222},"sCsY4","// Initiate database with SQLite connector\n",[173,225,227,230,234,237,241,244,247],{"class":175,"line":226},5,[173,228,229],{"class":179},"const",[173,231,233],{"class":232},"suiK_"," db",[173,235,236],{"class":179}," =",[173,238,240],{"class":239},"shcOC"," createDatabase",[173,242,243],{"class":183},"(",[173,245,246],{"class":239},"sqlite",[173,248,249],{"class":183},"({}));\n",[173,251,253],{"class":175,"line":252},6,[173,254,216],{"emptyLinePlaceholder":215},[173,256,258],{"class":175,"line":257},7,[173,259,260],{"class":222},"// Alternative:\n",[173,262,264],{"class":175,"line":263},8,[173,265,266],{"class":222},"// `using` automatically closes the database connection\n",[173,268,270],{"class":175,"line":269},9,[173,271,272],{"class":222},"// once the `db` variable goes out of scope  (for example, the function execution ends)\n",[173,274,276],{"class":175,"line":275},10,[173,277,278],{"class":222},"// await using db = createDatabase(sqlite({}));\n",[173,280,282],{"class":175,"line":281},11,[173,283,216],{"emptyLinePlaceholder":215},[173,285,287],{"class":175,"line":286},12,[173,288,289],{"class":222},"// Create users table\n",[173,291,293,296,299,302,305],{"class":175,"line":292},13,[173,294,295],{"class":179},"await",[173,297,298],{"class":183}," db.",[173,300,301],{"class":239},"sql",[173,303,304],{"class":190},"`CREATE TABLE IF NOT EXISTS users (\"id\" TEXT PRIMARY KEY, \"firstName\" TEXT, \"lastName\" TEXT, \"email\" TEXT)`",[173,306,194],{"class":183},[173,308,310],{"class":175,"line":309},14,[173,311,216],{"emptyLinePlaceholder":215},[173,313,315],{"class":175,"line":314},15,[173,316,317],{"class":222},"// Add a new user\n",[173,319,321,323,326,328,331],{"class":175,"line":320},16,[173,322,229],{"class":179},[173,324,325],{"class":232}," userId",[173,327,236],{"class":179},[173,329,330],{"class":190}," \"1001\"",[173,332,194],{"class":183},[173,334,336,338,340,342,345,348,351],{"class":175,"line":335},17,[173,337,295],{"class":179},[173,339,298],{"class":183},[173,341,301],{"class":239},[173,343,344],{"class":190},"`INSERT INTO users VALUES (${",[173,346,347],{"class":183},"userId",[173,349,350],{"class":190},"}, 'John', 'Doe', '')`",[173,352,194],{"class":183},[173,354,356],{"class":175,"line":355},18,[173,357,216],{"emptyLinePlaceholder":215},[173,359,361],{"class":175,"line":360},19,[173,362,363],{"class":222},"// Query for users\n",[173,365,367,369,372,375,378,381,384,386,388,391,393,396],{"class":175,"line":366},20,[173,368,229],{"class":179},[173,370,371],{"class":183}," { ",[173,373,374],{"class":232},"rows",[173,376,377],{"class":183}," } ",[173,379,380],{"class":179},"=",[173,382,383],{"class":179}," await",[173,385,298],{"class":183},[173,387,301],{"class":239},[173,389,390],{"class":190},"`SELECT * FROM users WHERE id = ${",[173,392,347],{"class":183},[173,394,395],{"class":190},"}`",[173,397,194],{"class":183},[173,399,401,404,407],{"class":175,"line":400},21,[173,402,403],{"class":183},"console.",[173,405,406],{"class":239},"log",[173,408,409],{"class":183},"(rows);\n",[173,411,413],{"class":175,"line":412},22,[173,414,216],{"emptyLinePlaceholder":215},[173,416,418],{"class":175,"line":417},23,[173,419,420],{"class":222},"// Using static parameters\n",[173,422,424,426,429,431,434],{"class":175,"line":423},24,[173,425,229],{"class":179},[173,427,428],{"class":232}," tableName",[173,430,236],{"class":179},[173,432,433],{"class":190}," \"users\"",[173,435,194],{"class":183},[173,437,439,441,443,445,447],{"class":175,"line":438},25,[173,440,229],{"class":179},[173,442,371],{"class":183},[173,444,374],{"class":232},[173,446,377],{"class":183},[173,448,449],{"class":179},"=\n",[173,451,453,456,458,460,463,466,469,471,473],{"class":175,"line":452},26,[173,454,455],{"class":179},"  await",[173,457,298],{"class":183},[173,459,301],{"class":239},[173,461,462],{"class":190},"`SELECT * FROM {${",[173,464,465],{"class":183},"tableName",[173,467,468],{"class":190},"}} WHERE id = ${",[173,470,347],{"class":183},[173,472,395],{"class":190},[173,474,194],{"class":183},[173,476,478,480,482],{"class":175,"line":477},27,[173,479,403],{"class":183},[173,481,406],{"class":239},[173,483,409],{"class":183},[110,485,486],{},[113,487,488,489,493,494,497,498],{}," > ",[490,491,492],"strong",{},"Static Parameters"," are a way to use string-literals other than places where prepared statements are supported, for eg. table name. ",[490,495,496],{},"DO NOT USE"," static parameters from untrusted source such as request body. ",[490,499,500],{},"STATIC PARAMETERS ARE NOT SANITIZED",[144,502,504],{"id":503},"next-steps","Next steps",[506,507],"read-more",{"to":23},[506,509],{"to":84},[511,512,513],"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 .sCsY4, html code.shiki .sCsY4{--shiki-light:#6A737D;--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .suiK_, html code.shiki .suiK_{--shiki-light:#005CC5;--shiki-default:#79B8FF;--shiki-dark:#79B8FF}html pre.shiki code .shcOC, html code.shiki .shcOC{--shiki-light:#6F42C1;--shiki-default:#B392F0;--shiki-dark:#B392F0}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);}",{"title":169,"searchDepth":197,"depth":197,"links":515},[516,517],{"id":146,"depth":197,"text":147},{"id":503,"depth":197,"text":504},"db0 provides an easy way to connect and query sql database providers.","md",{"icon":10},{"icon":10},{"title":5,"description":518},"WC9ELzd9Gp2DXasDO4LDRM8ra9rgT081MRdPiJnmNT0",[525,526],null,{"title":12,"path":13,"stem":14,"description":527,"icon":15,"children":-1},"Expose SQL databases over (secure) HTTP as a restful API for edge runtimes!",1780492437511]