Entity classes

Is it possible to have Drizzle automatically map returned entities to classes? We're looking at using Drizzle ORM but need classes to apply property decorators and automapper.
6 Replies
woubuc
woubucOP12mo ago
If not classes, are there other convenient ways to handle auto mapping and decorator-like stuff for Drizzle entities?
Angelelz
Angelelz12mo ago
Tables are classes under the hood The table function returns a class. You might need to dive into the codebase to see if you want to extend those classes to add the functionality yo want
woubuc
woubucOP12mo ago
That's for the tables. But the entities returned from a query aren't classes, right? I can't do orm.select().from(users) and have it return an array of instances of a User class - they're just plain objects. Or am I missing something?
Angelelz
Angelelz12mo ago
Oh yeah, no. It will be a plain object or array
woubuc
woubucOP12mo ago
So does anyone have tips or pointers how to do stuff like mapping the ORM entities to DTOs for public APIs? Any libraries that work nicely with Drizzle? Or do y'all do all that manually?
Kon-Viction
Kon-Viction9mo ago
I'd really like something like that as well, particularly for queries using the "with" operator to get entries from other tables typed with specific classes
Want results from more Discord servers?
Add your server