Generic `select`

trying to make generic selects. How can I do this? My attempt right now

// Fetch active quests from the database
export async function fetchActiveQuests<TSelection extends SelectedFields>(fields: TSelection) {
    return Sentry.startSpan({ name: 'loadQuests' }, async () => {
        // Get active escrow accounts from HoldCo
        const activeEscrows = await holdco().accounts.getActiveEscrows();

        // Get all quests that have holdcoIds matching the active escrows
        if (!activeEscrows.accounts || activeEscrows.accounts.length === 0) {
            return [];
        }

        // Extract the holdcoIds from the active escrows
        const activeEscrowIds = activeEscrows.accounts.map((account) =>
            account.main_account.id.toString()
        );

        // Query the database for quests with matching holdcoIds
        return db
            .select(fields)
            .from(quest)
            .where(eq(quest.isActive, true) && inArray(quest.holdcoId, activeEscrowIds))
    });
}


However the type I am getting is

function fetchActiveQuests<TSelection extends SelectedFields>(fields: TSelection): Promise<any[]>


(return type should not be any[] ideally!
image.png
Was this page helpful?