Open sz3lbi opened 8 months ago
Hi @sz3lbi , thanks for reaching out! If your setup does not allow top level await (non esm projects) I believe it's not possible unless drizzle allows async configuration load in some way. In fact from the drizzle repo issues, there are a few requests in that direction: https://github.com/drizzle-team/drizzle-orm/issues/1187.
The idea of this tool was mainly to have an async behaviour so we could have adapters to load configurations from external sources. With dotenv
package is possible because of its sync behaviour. What you are asking would be possible in this tool if I provide a loadConfigSync
where we only have/allow sync adapters (in fact the built in adapters that i provide can be like that). I will consider this for the next release! ;)
I would like to use this package in a project that uses Drizzle ORM.
I want to configure migrations, so I need to configure the database connection.
Here's what it should look like according to the Drizzle ORM docs:
(https://orm.drizzle.team/docs/migrations)
However, Node.js doesn't allow for top-level awaits that your tool returns when using
loadConfig
(in my case withdotenv
).Any tips on how to make it work?
PS. I was looking for a tool that would allow me to have a really type safe env variables in my application and this looks like a good fit. Thanks for creating it.