schemats icon indicating copy to clipboard operation
schemats copied to clipboard

db types

Open vitaly-t opened this issue 8 years ago • 4 comments

This is not an issue, just a thought...

I have seen so many projects at this point that keep re-doing the same thing - trying to map database types into TypeScript types.

So I've just started scratching something with db-types, in an attempt to bring it under one roof.

Any thoughts are welcome!

vitaly-t avatar Apr 23 '17 12:04 vitaly-t

I think it's a good idea, deciding how it should be mapped is a lot of responsibility for this project to take on, and everyone will have their unique needs. This and support for user defined mappings would really help us expand to db flavours that we are less familiar with.

crispmark avatar Apr 24 '17 02:04 crispmark

It's a nice initiative. I've thought about creating something like this before, but I ended up realizing I only cared about the types I use :joy:

xiamx avatar Apr 24 '17 02:04 xiamx

Thanks, guys! I'm still in the process of trying to formulate what it should be and how it should work.

At some point I was even considering turning it into a set of static, predefined TypeScript classes that declare all the mappings and provide generic methods for working with the data types.

In fact, I'm still considering it.... because in the end of the day, this is exactly what we expect as the output, no more no less.

The alternative, and is how the project is set up now, is to use generic JSON with all the type details, and then provide API for generic data type search.

There is also a third - mixed approach: to provide both JSON configurators with search methods, plus a method for generating all the TypeScript files, plus include the generated TypeScript files into the project, so one can use them directly.

What do you think?

vitaly-t avatar Apr 24 '17 09:04 vitaly-t

I'm more learning towards option 1, a more or less language central approach. I think using metadata reflection of TypeScript, you can still generate those JSONs from TypeScript classes.

xiamx avatar Apr 24 '17 16:04 xiamx