-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a006327
commit 4377984
Showing
49 changed files
with
1,038 additions
and
8,424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3.8' | ||
|
||
services: | ||
db: | ||
image: postgres:13 | ||
container_name: my_postgres | ||
environment: | ||
POSTGRES_DB: mydb | ||
POSTGRES_USER: myuser | ||
POSTGRES_PASSWORD: mypassword | ||
ports: | ||
- "5434:5432" | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
|
||
volumes: | ||
postgres_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import { SQLocalDrizzle } from "sqlocal/drizzle"; | ||
import { drizzle, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy"; | ||
import { drizzle, type PgliteDatabase } from "drizzle-orm/pglite"; | ||
import { PGlite } from "@electric-sql/pglite"; | ||
import * as schema from "./schema"; | ||
import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core"; | ||
|
||
export const SQLITE_FILENAME = "workbench.db"; | ||
let db: PgliteDatabase<typeof schema> | undefined = undefined; | ||
|
||
let db: SqliteRemoteDatabase<typeof schema> | undefined = undefined; | ||
|
||
export function useDb(): BaseSQLiteDatabase<any, any, typeof schema> { | ||
export function useDb(): PgliteDatabase<typeof schema> { | ||
if (!db) { | ||
const { driver, batchDriver } = new SQLocalDrizzle(SQLITE_FILENAME); | ||
db = drizzle(driver, batchDriver, { schema }); | ||
const client = new PGlite("idb://workbench-data"); | ||
db = drizzle(client, { schema }); | ||
} | ||
return db; | ||
} | ||
|
||
export function useDbFile() { | ||
const { getDatabaseFile, overwriteDatabaseFile } = new SQLocalDrizzle(SQLITE_FILENAME); | ||
return { getDatabaseFile, overwriteDatabaseFile }; | ||
} | ||
// export function useDbFile() { | ||
// const { getDatabaseFile, overwriteDatabaseFile } = new SQLocalDrizzle(SQLITE_FILENAME); | ||
// return { getDatabaseFile, overwriteDatabaseFile }; | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.