diff --git a/packages/db/package.json b/packages/db/package.json index 9867e1111e..0d80560c7f 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -1,6 +1,6 @@ { "name": "@astrojs/db", - "version": "0.1.20", + "version": "0.1.21", "description": "", "license": "MIT", "type": "module", diff --git a/packages/db/src/runtime/db-client.ts b/packages/db/src/runtime/db-client.ts index 975dc280af..d323036eb7 100644 --- a/packages/db/src/runtime/db-client.ts +++ b/packages/db/src/runtime/db-client.ts @@ -7,6 +7,8 @@ import { type SQLiteTable } from 'drizzle-orm/sqlite-core'; import { z } from 'zod'; import { getTableName } from 'drizzle-orm'; +const isWebContainer = !!(process.versions?.webcontainer); + export async function createLocalDatabaseClient({ collections, dbUrl, @@ -16,7 +18,8 @@ export async function createLocalDatabaseClient({ collections: DBCollections; seeding: boolean; }) { - const client = createClient({ url: dbUrl }); + const url = isWebContainer ? 'file:content.db' : dbUrl; + const client = createClient({ url }); const db = drizzleLibsql(client); if (seeding) return db;