Execute ZCQL Query

Construct the Query

You must construct a ZCQL query on the required data set before you execute it. A sample SELECT query is shown below:

Copied//Construct the query to execute
let query = 'SELECT * FROM ShipmentData';

Execute the Query

The query object created in the step above is passed to the executeZCQLQuery() method. The zcql reference used here is the component instance defined earlier.

This will return a promise which will be resolved to an object. The content key will contain the array of row objects.

Copied//Execute the query by passing it
let zcql = app.zcql();
let zcqlPromise = zcql.executeZCQLQuery(query);
zcqlPromise.then(queryResult => {
      console.log(queryResult);
});

A sample response that you will receive is shown below. The response is the same for both versions of Node.js.

Node.js

Copied[
  {
    AlienCity: {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-13 13:49:19:475",
      CREATEDTIME: "2021-08-13 13:49:19:475",
      CityName: "Dallas",
      ROWID: "2136000000008508"
    }
  },
  {
    AlienCity: {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-16 15:55:32:969",
      CREATEDTIME: "2021-08-16 15:55:32:969",
      CityName: "Los Angeles",
      ROWID: "2136000000011002"
    }
  },
  {
    AlienCity: {
      CREATORID: "2136000000006003",
      MODIFIEDTIME: "2021-08-16 17:03:01:507",
      CREATEDTIME: "2021-08-16 16:29:10:499",
      CityName: "New York",
      ROWID: "2136000000011011"
    }
  }
]