function getUserByBaja(callback) { var _result = ""; var _ss = ""; var _index = 0; var syncAcc = []; require(['baja!'], function (baja) { baja.Ord.make("local:|foxs:|station:|slot:/Services/UserService|bql:select * from baja:User where enabled = 'true' and toString != 'defaultPrototype'").get() .then(function (table) { table.cursor({ each: function (item) { if (_index == 0) _ss += '{"Account": "' + item.$map.$map.toString.$display + '"}'; else _ss += ',{"Account": "' + item.$map.$map.toString.$display + '"}'; _index++; }, after: function () { _result += '{' + '"count": ' + _index + ', "data":['; _result += _ss; _result += ']}'; if (typeof callback === 'function') { callback(_result); } }, limit: -1, offset: 0 }) }); }); }