tink_sql
tink_sql copied to clipboard
Extendable Table class?
I found myself writing the same query such as db.user.where(user.id == id).first() again and again.
I wonder if it is possible to extend the generated table and add methods like db.user.get(id)
Static extensions should work ;)
But yeah, let's see what we can do.
Static extensions should work ;)
I wonder what is the type of the generated table? Is it tink.sql.Table<User>?
Ok I figured it out:
class UserTableTools {
public static function get(table:Table<{user:User}>, id:Id<User>)
return table.where(user.id == id).first();
}