giovannibenussi
DTDrizzle Team
•Created by giovannibenussi on 2/1/2024 in #help
Error with NestJS + Turso in-memory database during testing
Hey everyone. First of all, I'm far from an expert with NestJS. However, I'm working on a test that mocks a database module as follows:
This works if you use
file:./test.db
instead of :memory:
. But when using the memory database it fails because there are no tables in the database.
What I know is that we run database migrations because it works when you use a file. However, for some reason the state is not persisted when using an in memory database.
Any ideas of what may be wrong in this case?14 replies
DTDrizzle Team
•Created by giovannibenussi on 1/15/2024 in #help
Get Schema From db instance
Hey! There's a way to get a table instance just from the
db
object?
Currently I have this:
await db.insert(users)...
And I want to provide a general function that performs an insert in a database:
However, I'd like to make the table dyamic (it's a plugin) so we can't depend on the users
object to be available and I'd like to avoid asking users to provide it as a parameter. There's a way to make it work?
The table needs to follow a given schema (specified in our docs), so I wonder if it's possible to get the schema similar to this (just pseudo-code 😅):
Thanks in advance for your help!15 replies