Creating an Unaggregated Query

Unaggregated queries provide an unmodified/raw view of the dataset where each set of field values represent a row of data. To create one, you can define a query configuration object with the set of fields you want to request. You also need to provide an object with the Zoomdata data source name when calling the createQuery method of the client instance.

Example:

// create the query configuration object
const queryConfig = {
  fields: [{ name: 'payment_type', limit: 5 }, { name: 'country' }],};

// create an object with the Zoomdata source name to use when running the query.
// In our example, the source name = 'Sales'
const source = {
  name: 'Sales',
};

/**
 * Used to create a data query.
 * 
 * Result of running this function can be later used as input for client.runQuery.
 * @param {SourceObject} source Object with a single key, name, that gives the name of the data source being queried, or data source model.
 * @param {QueryConfig} config Query options.
 * @returns {Promise} Promise with QueryAPI object. It can be used as input for client.runQuery method
 * @example
 */
client.createQuery(source, queryConfig);

The createQuery method returns a JavaScript Promise that resolves with a queryAPI object.

In the above example, the query requests a set of payment_type and country values limited to 5 rows of data. The first requested field specifies the row limit for the entire query.

Try this example on CodeSandbox

It should output the queryAPI object to the console.

Updated Jan 10, 2019