Skip to content

Attribute

This is the object that the .groupby() function expects as parameters. It represents the field used to aggregate a query.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// A normal attribute
var event = cf.Attribute('eventname')
                .limit(20)
                .sort('desc',metricObject)

// A time attribute
var saletime = cf.Attribute('saletime')
                    .sort('asc', 'saletime')
                    .func('DAY')
                    .limit(1000)

The Attribute constructor takes the name of the field existing in the data engine. limit() is the max number of results to be retrieved for that attribute. sort() takes two parameters, the first one is the sort order ('asc' or 'desc'), and the second is based on what is going to be sorted. It can be a Metric object or the string with the name of the same field, which will mean then that is going to be alphabetically sorted (or reverse alphabetically if is 'desc'). For the second case we also have .func(). This only applies to time attributes. And it depends on the minimum granularity of the data. The possible values for this are: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH and YEAR. If the data is in date format for example, we can not tell the object to use SECOND or MINUTE, this will be possible only it is in datetime format. If the data represents monthly events for example, there is no point in using DAY but MONTH or YEAR.