Open Parilar opened 6 years ago
Indeed
How can we solve?
Currently, there is no way to know number of pages. Can be a feature going ahead. As a work around you can call api to know count and work the number of pages if its absolutely required.
API returns 20 objects by default, just make count / 20 to know how many pages you have :)
I've monkeypatched Xsql to overcome that hardcoded limit for my usecase
const MAX_ROWS = 10000;
// monkeypatch overwrite 100 limit :)
Xsql.prototype.getLimitClause = function getLimitClause(reqParams: any) {
reqParams._index = 0;
reqParams._len = 20;
if ("_size" in reqParams) {
if (parseInt(reqParams._size) > 0 && parseInt(reqParams._size) <= MAX_ROWS) {
reqParams._len = parseInt(reqParams._size);
} else if (parseInt(reqParams._size) > MAX_ROWS) {
reqParams._len = MAX_ROWS;
}
}
if ("_p" in reqParams && parseInt(reqParams._p) > 0) {
reqParams._index = (parseInt(reqParams._p) - 1) * reqParams._len;
}
//console.log(reqParams._index, reqParams._len);
return [reqParams._index, reqParams._len];
};
Try it not very optim for front
getTableByEntytiWhere(entity, whereField,likeField) {
return new Promise<any>((resolve, reject) => {
let resultTable = [];
this.http.get(this.apiUrl + "locations/" + entity + "/count?_where=("+whereField+",like,"+likeField+")").subscribe(async (res) => {
let loops = Math.trunc(parseInt(res[0].no_of_rows) / 100) + 1;
for (let index = 0; index < loops; index++) {
let resultQuery = await new Promise<any>((resolve, reject) => { this.http.get(this.apiUrl + "locations/" + entity + "?_where=("+whereField+",like,"+likeField+")&_p=" + index + "&_size=100").subscribe((res)=>resolve(res),(err)=>{reject(err)})});
resultQuery.forEach(element => {
resultTable.push(element);
});
;
}
resolve(resultTable);
});
});
}
Any news on this one? I'm hitting this as well. One thing to note is that query I'm using does a descending sort and the arbitrary objects returned in the first 20 will be sorted, but they do not represent the top 20 sorted rows of the entire set.
eg for a row with a field vid
set to an int, and the entire set is vid=[1..30]
, my sorted query might return 5 as the lowest and 25 as the highest, and the results vary for the same repeated request
Hey, is there a way to disable the maximum ? Why is there a maximum of 100