Skip to main content
npm version This is a simple library to create data query URLs for Getting Domo data. Use in conjunction with domo.js.

Installation

The Query library is available on npm

Overview

Examples

Usage

Building a Query

This section will explain the options available to you for building queries. Here is an example of a complex query.
Note:
  • Refer to the Date Range Filtering section for accepted values for the dateGrain and periodToDate functions.
  • Refer to the Order By section for accepted values for the orderBy function.

Selecting Columns

Use select to specify the column names for the columns you want returned.
Column names are the alias names specified in the manifest.json file.

Data Filtering

Filter data by using the where(columName) function followed by the desired filter function.

Filter Functions

Date Filtering

The lt, lte, gt, gte, between filter functions will filter dates when used on a column that is a date. Other functions will treat the date as a string.

Date Range Filtering

Columns that are dates can be filtered using specific ranges: previousPeriod, rollingPeriod, periodToDate.
NOTE: Only 1 date range filter may be used in a query.
A DateGrain enum and a RollingDateGrain enum are provided with the valid interval options. These are:

Previous Period

Data for last year, last month, etc can be requested by using the previousPeriod function. This is how you would get data from last year when the date column is named salesdate:
Note:
Rolling Period
A rolling period can be requested by using the rollingPeriod function. For example, this is how you would get all data from the last 6 months when your date column is named salesdate:
Note:
Period to Date
Period-to-date filtering is done using the periodToDate function. For example, this is how you would get year to date data when the date column is named salesdate:
Note:

Group By

Data can be transformed to a group-by operation using the groupBy function. Aggregations for columns can be specified in an object where the key is the column name, and the value is an Aggregation. By default, columns are counted.
Note:
  • Refer to the Aggregation section for accepted values for the Aggregation parameter.
The grouping above would make this data:
colorshapequantity
redsquare3
greensquare14
bluesquare4
purplesquare9
orangecircle3
redcircle14
greencircle4
bluecircle9
purpletriangle3
orangetriangle14
redtriangle4
greentriangle9
bluesquare3
purplesquare14
orangesquare4
redsquare9
Become aggregated like so:
colorshapequantity
red430
orange321
purple326
green327
blue316

Date Grain

Data can be “grained” by date by using the dateGrain function. This is a special type of “group by”.
Note:
  • Only 1 column may be date grained in a query.
  • Refer to the Date Range Filtering section for accepted values for the DateGrain parameter.
This query would group together all data in the data source by month. Each row in the returned data would represent a summary of that data for the month.” Like groupBy column aggregations may be specified.

Aggregation

Accepted aggregation values are 'count', 'sum', 'avg', 'min', 'max', or 'unique'. You can use data aggregations to
  1. Consolidate all rows of a column into a single value.
  2. Specify the aggregation type for date grain and group by queries.
This is done with the aggregate function. For example, to specify the aggregations for fields salesTotal and salesAmount as sum and average respectively:

Order By

Rows can be ordered by any column in 'ascending' or 'descending' order using the orderBy function. An enum (OrderByDirection) is provided to define the order by direction. Valid orderings:

Limit

For improved performance and latency, you can paginate data using limit and offset.

Offset

To offset the data you get by a certain number, use offset.

Fiscal Calendar

You can specify to use the instances fiscal calendar for date-related operations such as previousPeriod or dateGrain with useFiscalCalendar(true). The standard calendar is used by default.

Beast Modes

You can enable beast modes in the query by calling the useBeastMode. true