You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In ES module land, this works without issue. However, in Node-CJS land this does not work. Our only alternative is to export an async init method and use that wherever we'd like to access our database. That is quite common and normal for folks who are still working in CJS. There is a pattern that could be used to alleviate the need for an async init method - allowing for asyn configuration. Bundlers like Vite, Webpack, and Rollup all support async configs for this kind of purpose, so there is some prior art there. One such implementation might look like:
drizzle(async()=>{constdbUrl=awaitgetRemoteSecret('DB_URL');constpool=newPool({connectionString: dbUrl});return{client: pool, schema };})
Given how the result of drizzle is typically used, that might require some fancy use of Proxy.
I noticed there were a few other issues open about top-level await and an older reverted commit which might be solved by this approach.
The text was updated successfully, but these errors were encountered:
We're having the same exact issue! We've coded a work around, but it is not ideal and makes the app extremely slow. Is there a plan to allow for Async calls to inject our credentials like requested above?
Describe what you want
At present drizzle has a traditional constructor/initializer with literal configuration properties. e.g.
Now consider that our DB Url is located in a secret manager/store, which requires an
async
request to fetch.In ES module land, this works without issue. However, in Node-CJS land this does not work. Our only alternative is to export an async
init
method and use that wherever we'd like to access our database. That is quite common and normal for folks who are still working in CJS. There is a pattern that could be used to alleviate the need for an asyncinit
method - allowing for asyn configuration. Bundlers like Vite, Webpack, and Rollup all support async configs for this kind of purpose, so there is some prior art there. One such implementation might look like:Given how the result of
drizzle
is typically used, that might require some fancy use ofProxy
.I noticed there were a few other issues open about top-level await and an older reverted commit which might be solved by this approach.
The text was updated successfully, but these errors were encountered: