Is it possible to create generic schema proxy?

<TSchema extends Record<string, unknown>, TDb extends PostgresJsDatabase<TSchema>>

something like that should be ok, but I got errors in type:
type FindFn<TK extends keyof typeof db.query = keyof typeof db.query> = (
        ...args:
            | Parameters<(typeof db.query)[TK]['findFirst']>
            | Parameters<(typeof db.query)[TK]['findMany']>
        ) =>
        | ReturnType<(typeof db.query)[TK]['findFirst']>
        | ReturnType<(typeof db.query)[TK]['findMany']>;
Was this page helpful?