SweetIQ/schemats

Support passing pg-promise initialization options during the library's initialization

Opened this issue · 5 comments

It would be nice to be able to pass initialization options or a configuration object directly to pg-promise.

This could be fairly easily be possible if you

  1. Allow either a PgPromise.IDatabase or a string directly to be passed to the PostgresDatabase constructor.
  2. Export PostgresDatabase from index (should also maybe export MysqlDatabase too)

In general, it might be worth double checking to see if there are other useful classes/functions that should be exported too.

xiamx commented

I think allowing the constructor to be extended with options is a good choice. Please make a pull request and let's look at it together. Also could you elaborate on what you want to build on top of schemats, I'm very curious.

Also could you elaborate on what you want to build on top of schemats, I'm very curious.

My sentiment exactly, what options of pg-promise is he planning to use that would be beneficial here?

@xiamx I actually have (at least for now) decided that this is a bit heavy for me to implement/use (for now, at least), and I can't really devote time to make a pull request currently, sorry.

I was planning to use this to generate types during build/development. The project I work on has some special logic for getting the database configuration, and use that as a configuration object for pg-promise in the main source.

I didn't have a specific idea for initialization options though.

As I said, I won't be using this right now, so feel free to close this issue if you don't think it's needed.

xiamx commented

Cool so I changed the title to a more descriptive one. We will keep this one open for visibility.

@xiamx It's nice, but I don't see it being of any use, because this library is only used for generating code, and all the options in pg-promise relate to the run-time in-app usage only, nothing to do with the code generation. I don't understand why this issue was open to begin with.