OED icon indicating copy to clipboard operation
OED copied to clipboard

sync JavaScript enums with PostgreSQL

Open lindavin opened this issue 4 years ago • 2 comments

In our PostgreSQL database, we use enums for meter types. We also supply logical names for these types as an enum in the Meter class. These two enums need to be kept in sync, i.e. if we make changes to either one these enums in the future, we need to remember to change the other.

lindavin avatar Feb 22 '21 16:02 lindavin

Hello! Can I create a folder named "shared" which contains meterTypes.js and meterTypes.ts, which can export the type nums. Then I import one in src/client/app/types/redux/meters.ts , and import another in src/server/models/Meter.js? Since the two meterTypes file are in one folder, poeple will probably remember to keep them in sync.

RuxueJ avatar Feb 24 '24 05:02 RuxueJ

@RuxueJ Thanks for this idea. It is probably an improvement but I would like to see if there is a way to automatically keep the JS and TS in sync. If not, we could do what you suggest.

Also, this does not seme to address the direct issue of making the Postgres enums match the TS/JS ones. Any thoughts on that?

huss avatar Feb 24 '24 14:02 huss