Consider the following code :
function search(filter) {
var query = breeze.EntityQuery
.from("Mandates").skip(offset).take(pageSize).inlineCount(true);
if (queryParamCache[cacheObj] > 0) {
query = query.using(breeze.FetchStrategy.FromLocalCache);
} else {
query = query.using(breeze.FetchStrategy.FromServer);
}
return manager.executeQuery(query.using(service)).then(function (result) {
return result;
});
}
queryParamCache is used as a flag to find out if the query results are already in cache.
Now, if I call this method and set offset to 120 in order to skip the first 12 pages (10 records per page), a call is made to the server and results are displayed.
Then, I make the same call for page 13, which works, and I go back to page 12. This time records are fetched from the cache, which is what I want.
But in breezejs code, in the function executeQueryLocally, the following code is executed:
var skipCount = query.skipCount;
if (skipCount) {
result = result.slice(skipCount);
}
skipCount is set to 120, but obviously this just deletes everything in the array, since I only had 20 records (page 12 and page 13).
Is this not a bug ? Or did I miss something ?