Mapping: stringcase conversion on introspection #2873
Labels
kind/feature
A request for a new feature.
team/schema
Issue for team Schema.
topic: introspection
topic: introspection-configuration
Problem
Manual mapping using @Map() and @@Map()
I've found a little bit off-putting the fact of having to map manually all columns and tables for a database of 110 tables, where the database is snakecase'd and the code is camelcase'd.
I think it would be beneficial if an option to automatically map table names and columns were in place
Suggested solution
I see a possible solution by just using a library like "knex-stringcase" (https://github.com/Kequc/knex-stringcase#readme). It would be used when generating the prisma schema via
introspection
command.A new option in
prisma.schema
could be added such as (same way as knex-stringcase does)So that, a prisma model name could be generated on introspection with the corresponding @Map() clauses
Example, after running
$ npx prisma introspect
I get the following model definition for my explicit n:m relationshipi get
However, if I ran
The result, automatically, would be
In a next iteration, the ability to distinguish between model name and model attributes would be ideal since you might want to have your model name capitalized but not the attribute.
I hope my feature suggestion is clear enough,
Thanks!
The text was updated successfully, but these errors were encountered: