zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

[Feature request] Naming of column zenstack_guard #324

Closed jawadst closed 1 year ago

jawadst commented 1 year ago

Is your feature request related to a problem? Please describe.

We usually name our columns with camelCase rather than snake_case

Describe the solution you'd like

The ability to specify the name of the zenstack_guard field via an attribute in the Zmodel would be great

ymc9 commented 1 year ago

Good point. Let me think about where to add such a setting. It can be translated as a @map in Prisma schema.

ymc9 commented 1 year ago

I think we can introduce a zenstack.config.json file to configure this behavior globally. Will include it in the next release.

ymc9 commented 1 year ago

Hey @jawadst , I've worked on a PR to add a zenstack.config.json file for CLI settings, right now only include the customization you need. The file is optional but can be created as follows:

{
    "guardFieldName": "myGuardField",
    "transactionFieldName": "myTransactionField"
}

With this, the Prisma schema generated will be:

model Foo {
    ...
    zenstack_guard Boolean @default(true) @map("myGuardField")
    zenstack_transaction String? @map("myTransactionField")
}

Does this look good to you?

In the future we may change the field to camel case by default, but I think we should probably do it on a major release since it causes a new db migration.

jawadst commented 1 year ago

@ymc9 Looks perfect, thanks a lot!

ymc9 commented 1 year ago

Fixed by #340