norm icon indicating copy to clipboard operation
norm copied to clipboard

ability mapping model's field to different column name

Open toghrulgasimov opened this issue 2 years ago • 5 comments

is there a way to change column name of model in database?

toghrulgasimov avatar Dec 21 '21 16:12 toghrulgasimov

Out of curiosity, what would be the point of that ?

Clonkk avatar Dec 21 '21 17:12 Clonkk

Out of curiosity, what would be the point of that ?

Probably connecting Norm to an existing table.

This can be implemented in a similar manner to tableName pragma: https://github.com/moigagoo/norm/pull/123/

moigagoo avatar Dec 21 '21 18:12 moigagoo

Probably connecting Norm to an existing table.

I can fully confirm that this would be the usecase, at least for me. In my case, I've got a table generated from another framework from which I'm rewriting the backend. That gave me lots of columns with an _id suffix. Currently I'm writing my models in a way that I have an entire instance of a Campaign object sitting behind a fieldName of campaign_id, which is a somewhat confusing read for somebody uninitiated.

PhilippMDoerner avatar Jan 07 '22 18:01 PhilippMDoerner

Same here. If Norm had more support for using existing databases, I would definitely consider to use it in many more places.

saemideluxe avatar May 18 '22 08:05 saemideluxe

I'll take a look at this. Shouldn't be too hard.

However, custom primary keys have higher priority to me.

moigagoo avatar Jun 04 '22 07:06 moigagoo