apstanisic / zmaj

Zmaj is a headless CMS for managing database
https://zmaj.vercel.app
MIT License
5 stars 0 forks source link

Customize collection and field name #31

Closed apstanisic closed 1 year ago

apstanisic commented 1 year ago

This complicates code since there is difference between column and field, table and collection. It also means that infra state must store more data. That additional data also contributes to admin panel bundle size.

Camel case pros:

Cons:

apstanisic commented 1 year ago

It wasn't fully. It's a useful abstraction that means that user can user same API even if their db changes. But it was definitely a mistake to do it by default, since it made writing docs much harder. Ideally, this option would be exposed to user, so they can set it how they want

apstanisic commented 1 year ago

Provide option if user wants to camel case columns, and that value should be user. Find all instances that you depend on camel casing and snake casing and replace them will dynamic implementation

apstanisic commented 1 year ago

This requires additional data in database, since currently we infer field name from database, but if we want custom values, we would have to store that info

apstanisic commented 1 year ago

This is also convenient if user has legacy database, and they want to create different API

apstanisic commented 1 year ago

Add field for collection name when creating, and always use that value. If it's empty string, generate default value (camel case). For existing table on sync, default to camel case

apstanisic commented 1 year ago

This complicates syncing with db a little, since some field might have a name of a column. But this is also a big plus when migrating code