Creating a Generic Database Service in TypeScript

Hello! Is there a way to create a generic service? My initial thought was something like this:

class DbService<Schema> extends Context.Tag("DbService")<
  DbService<Schema>,
  DrizzleD1Database<Schema>
>() {}


But it doesn't work, because Base class expressions cannot reference class type parameters. I would like to do this because I'm working on a monorepo, and want to have a generic db implementation, where each app can provide it's own schema, and other packages (such as auth, billing, etc.) can use this generic service to interact with the db
Was this page helpful?