BlueForge Docs

client.aggregate

Run an aggregate query (count, sum, avg, min, max)

Signature

class Client {
  aggregate<T>(table: string, opts: { fn: string; column?: string; groupBy?: string }): Promise<unknown>
}

Parameters

ParamTypeRequiredDescription
table
string
yesTable name
opts
{ fn: string; column?: string; groupBy?: string }
yesAggregate options (fn: count|sum|avg|min|max, column?, groupBy?)

Examples

import { Client } from '@blueforge/client'
const bf = new Client({ apiKey: process.env.BF_API_KEY!, url: 'https://your-project.blueforge.dev' })

const result = await bf.aggregate('orders', { fn: 'sum', column: 'amount', groupBy: 'status' })

Throws

ErrorCondition
ApiError
API request failed
NetworkError
Network issue

Pitfalls

  • Performance — aggregate queries scan the entire table; add
    WHERE
    filters in the query builder for large datasets
  • Type safety — the column must support the aggregate function (e.g.
    AVG
    on a text column fails at runtime)

See also

{auto-injected}

Tested against

{auto-injected}