prorm API Reference
    Preparing search index...

    Interface FnExpression

    Represents a SQL function expression Used in attributes to create aggregate queries

    // Count all records
    User.findAll({
    attributes: [[fn('COUNT', col('id')), 'count']]
    })

    // Count distinct values
    User.findAll({
    attributes: [[fn('COUNT', fn('DISTINCT', col('role'))), 'uniqueRoles']]
    })

    // Sum with group by
    User.findAll({
    attributes: ['role', [fn('SUM', col('score')), 'totalScore']],
    group: ['role']
    })
    interface FnExpression {
        __type: "fn";
        fn: string;
        args: any[];
    }
    Index
    __type: "fn"
    fn: string
    args: any[]