Using Data tools: readRecords vs getColumn

getColumn is implemented the same as readRecords. The difference is that App Lab provides the callback function. See also getColumn: one common error and one subtle error explained.

The difference is as follows, readRecords tells you when the data is available through a callback. If you want to know when two pieces of data are available just wait till the last of the two finishes to start to process the data.

getColumn uses a built in callback function written in the native Javascript. That means it runs about 200 times faster than any callback function you can write. That reduces the risk of trying to use data that isn’t there yet but doesn’t eliminate it.

Do you want fast or reliable?

I would just do something like this:

var HistoricalNonViolentResistances;
var Dogs;
var historicalNonViolentDone = false;
var dogsDone = false;

readRecords("Historical Non-violent Resistances",{}, function (data) {
  historicalNonViolentDone = true;
  HistoricalNonViolentResistances = data;
  if (dogsDone) {
    doIt();
  }
});

readRecords("Dogs",{}, function (data) {
  dogsDone = true;
  Dogs = data;
  if (historicalNonViolentDone) {
    doIt();
  }
});

function doIt(){
  console.log(HistoricalNonViolentResistances[HistoricalNonViolentResistances.length-1]);
  console.log(Dogs[Dogs.length-1]);
}
1 Like