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
woubucOP13mo ago
If not classes, are there other convenient ways to handle auto mapping and decorator-like stuff for Drizzle entities?
Angelelz
Angelelz13mo 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
woubucOP13mo 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
Angelelz13mo ago
Oh yeah, no. It will be a plain object or array
woubuc
woubucOP13mo 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-Viction10mo 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