electric-sql / electric-sql/pglite
Expo API routes resolves `postgres.data` to the lambda API directory, despite using an absolute DB path
- Dominant language
- TypeScript
- Stars
- 16k
- Forks
- 442
- Avg merge
- 20h 19m
- Merged PRs (30d)
- 7
Description
I am trying to use PGLite with Drizzle via Expo's API routes.
Here is my Drizzle DB instance init:

`process.cwd()` does resolve to the root project directory, which is supposed to contain my `.db` folder.
This is working when using a custom migration script that imports this `@/lib/db` file.
Unfortunately, when importing the same db instance (located at `@/lib/db`) from an API route, stored in `@/app/api/tests/db+api.ts`, PGLite tries to access the `postgres.data` file from that path, despite initializing the DB with the correct path (verified by `console.log`ging).

This is probably a problem either with Expo's handling of API routes (at least in dev mode), Metro, or more likely a skill issue of mine.
Figured it might be useful to post this here anyway, since Drizzle support with Expo is explicitly stated in docs - albeit not specifically using API routes, which might apparently actually require a different setup.
I'm still trying to figure this out on my end and will report back here if I manage to fix anything. Hope filing this issue was the right thing to do as well - if not, I apologize!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.