Aggregations in a query

const query = await db.query.folders.findMany({
            where: queryParams,
            columns: {
                ...folderSelector,
                hasFolders: sql<boolean>`EXISTS (SELECT 1 FROM ${folders} WHERE ${folders.parentId} = ${folders.id})`.as('hasFolders'),
            },
            with: {
                creator: userProfileSelector,
                organization: organizationUserSelector,
            },
        });

Hello, is there a way to do aggregation within a query.
Was this page helpful?