nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Support env variables in DB config

Open robin-dongbin opened this issue 1 year ago • 4 comments

Describe the feature

export default defineNitroConfig({
  database: {
    default: {
      connector: 'sqlite',
      options: { name: 'db' }
    },
    users: {
      connector: 'postgresql',
      url: 'postgresql://username:password@hostname:port/database_name'
    }
  }
})

Currently we define pgsql connection information in a configuration file. I think it's dangerous to expose connection information in config files

Additional information

  • [ ] Would you be willing to help implement this feature?

robin-dongbin avatar Mar 17 '24 11:03 robin-dongbin

Is there any progress on this? Was experimenting with using db0 with Nitro and this feels very awkward for configuration. Maybe just a set of standard env vars we can override.. e.g., NITRO_DB_DEFAULT_NAME=db or NITRO_DB_USERS_URL

mehcode avatar Dec 04 '24 19:12 mehcode

Yes, we should tackle this. Main thing is that since connector options are in total control of db0 connectors, we might need to expose this feature for db0 first. feel free to raise an issue there to track.

pi0 avatar Dec 04 '24 19:12 pi0

Maybe this could be somehow hooked up to useRuntimeConfig?

septatrix avatar May 07 '25 00:05 septatrix

feel free to raise an issue there to track.

--> unjs/db0: #166

septatrix avatar May 07 '25 00:05 septatrix