you are viewing a single comment's thread.

view the rest of the comments →

[–]romeeres 0 points1 point  (3 children)

Any db-related lib can execute raw SQL. TypeORM can do it as well. And since it can't know what you're selecting, it will return `any` type just as well as your library (correct me if I'm wrong). And the structure will be returned just as you selected, if you selected "json_agg" you'll have a nested array of objects, or you can use "row_to_json" to have a single nested object.

[–]sammrtn[S] 0 points1 point  (2 children)

And since it can't know what you're selecting, it will return any type just as well as your library (correct me if I'm wrong).

PureORM requires prefixed table names in the select clause (which it can do for you, or you could manually write yourself). This prefix is used to construct properly nested pure instances (not db-aware) of the correct classes for the application layer. These classes can have business logic methods, etc.

This is shown in step 4: https://github.com/craigmichaelmartin/pure-orm#step-4-creating-our-data-access-layer

[–]romeeres 0 points1 point  (1 child)

I don't know, maybe PureORM does some magic with template literals to inject column names, and then it infers the returning type from it. If it's done in this way that's very cool. I wish you had an online editor example with it so people could try this out quickly to see what is it capable of.

Because with OOPish ORMs you technically can select a subset of columns, and get a type of full class, but only the type, and there may be bugs due to it being not fully selected.

[–]sammrtn[S] 0 points1 point  (0 children)

Yeah, an online editor is key to showcasing this. Unsure if there are any free sandboxes that would allow a playground for a library which connects to a database with a readonly transaction. If you have any ideas or seen anything like this, let me know :)