pglite icon indicating copy to clipboard operation
pglite copied to clipboard

Support ORMs (Prisma, Drizzle ect.)

Open arvinxx opened this issue 1 year ago • 13 comments

arvinxx avatar Feb 26 '24 14:02 arvinxx

do it support prisma?

Not yet, we will be able to explore ORM support once we have #17 parameterized queries

samwillis avatar Feb 27 '24 09:02 samwillis

After #17 I will create a custom adapter for this with Kysely to play around with it.

alexgleason avatar Feb 27 '24 16:02 alexgleason

Also mentioned this on #8 but it would be awesome if pglite could support postgraphile ORM, I have a PoC that fails due to missing tables that are needed for introspection that I can share if there's interest.

kzlar avatar Mar 13 '24 17:03 kzlar

would like to add a vote for sequelize. Not sure if there's anything ORM specific or if it would basically be an engine swap

intellix avatar Apr 08 '24 01:04 intellix

Also mentioned this on #8 but it would be awesome if pglite could support postgraphile ORM, I have a PoC that fails due to missing tables that are needed for introspection that I can share if there's interest.

Curious how are you using postgraphile with pglite?

amerryma avatar Apr 08 '24 03:04 amerryma

After #17 I will create a custom adapter for this with Kysely to play around with it.

out of curiosity, have you started on it ? (no pressure, this is OSS :) )

sledorze avatar Apr 12 '24 16:04 sledorze

Also mentioned this on #8 but it would be awesome if pglite could support postgraphile ORM, I have a PoC that fails due to missing tables that are needed for introspection that I can share if there's interest.

Curious how are you using postgraphile with pglite?

I posted my PoC over on postgraphile's discord: https://discord.com/channels/489127045289476126/551374822521831424/1223313956668571758 The idea is to eventually have complete e2e testing with a single process - so no need to set up a postgres server that you need to set up and tear down for every test. Still a long way to go though :)

kzlar avatar Apr 13 '24 04:04 kzlar

Just an FYI I would like to see support for the following:

  • [ ] Kysely
  • [ ] Drizzle
  • [ ] TypeORM
  • [ ] Prisma

lastmjs avatar Apr 29 '24 11:04 lastmjs

What special work needs to be done to support these? I was hoping the API/interface was pretty basic and generic

lastmjs avatar Apr 29 '24 11:04 lastmjs

Context: we wanted to use PGLite to speed up our unit tests with an in memory version.

As a feedback to save time for people trying the same :

  • We had a problem with the single process nature (no isolation between Txs) - I understand why, docs are crystal clear, it's by design.
  • We had a problem with startup time and RAM consumption - because of test isolation as the runner creates as much in memory instances as files make necessary - this is logical and also by design

This is not a criticism against PGLite; those are the problems all other solutions based on the same usage of bringing 'native' PG in the runtime will have.

Beside that: Great library, thanks for all efforts !

sledorze avatar Apr 29 '24 12:04 sledorze

@lastmjs Drizzle now supports PGlite as of a couple week ago. I should have updated here!

For the others, PGlite should have everything needed to build adapters/plugins for them. I'm not sure we are going to do this ourselves due to a long list of core PGlite stuff to do first. I'm very happy to do any testing or bug fixes to help out with building extensions.

For the Drizzle support they did the majority of the work and then I did a pass over it once they had tests running to fix any failures (at the time mostly our side). I am more than happy to do the same again!

samwillis avatar Apr 29 '24 17:04 samwillis

@sledorze we have a few ideas around how to improve memory usage and startup time for unit/integration testing.

What I would love to do is create a method to fork an in memory PGlite with copy-on-write of the VFS (and maybe the heap+stack, but I suspect that's hard). You could then create the database and load any data once, but then create a clean fork for each test. This should be super quick with relatively low memory usage per fork. It's not on the roadmap currently, but I hope we can look at it at some point.

samwillis avatar Apr 29 '24 17:04 samwillis

Hi @lastmjs ,

Is it possible to support Parse Server? Since it supports the stardard pgsql. Thanks very much. https://github.com/parse-community/parse-server

xeoshow avatar May 18 '24 10:05 xeoshow

@alexgleason did you ever to get writing an adapter for Kysley?

nicksrandall avatar May 31 '24 00:05 nicksrandall

@alexgleason did you ever to get writing an adapter for Kysley?

I could never get it working in Deno, so I gave up. It wouldn't be hard to do, though. Just fork the official postgres dialect: https://github.com/kysely-org/kysely/tree/master/src/dialect/postgres and modify executeQuery

alexgleason avatar May 31 '24 01:05 alexgleason

Eagerly waiting for this support. Make it happen.

sukeshpabolu avatar Jun 26 '24 09:06 sukeshpabolu