mirror of
https://github.com/withastro/astro.git
synced 2025-04-07 23:41:43 -05:00
Make work in webcontainer
This commit is contained in:
parent
e0545d0cf3
commit
4e55fd0f56
2 changed files with 5 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@astrojs/db",
|
||||
"version": "0.1.20",
|
||||
"version": "0.1.21",
|
||||
"description": "",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue