Ionic app how do I use the Rest API to Query some data and cache the data

When I use the REST API the data caches if I leave the command blank, or add a cache. But once I add in some where.parameters the data doesn't seem to cache anymore.

_.set(requestData, 'where.companyId.collName','tblCompanies');
_.set(requestData, 'where.companyId._id', companyId_scope);
_.set(requestData, 'cached', true);

return requestData;
/*CLICK TO EDIT MAPPING*/
})($scope);

Apperyio.get("API_tblCustomer_find")({requestData}).then(

I can disable the first two lines and the data caches. Or I can keep the first two lines and I get the dataset I want - but the data doesn't cache and is lost when I am offline.

Thanks for your help.
1 person has
this question
+1
Reply
  • Hello Jackson,

    Please see the information about the caching in the API Express: https://docs.appery.io/docs/apiexpres...

    What exactly do you need to cache?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Thank you for the reply. Unfortunately I've read that and it didn't help me when it came to a practical application. I perform a rest api find query that returns a list of clients. The list is queried based on the users company id. If I query the data with no filter the data is cached on the app and can be viewed online and offline. Once I apply the filters the data only appears online. I assume I am somehow passing the query and caching parameters incorrectly inn ionic. What is the correct way to pass query parameters without losing the caching function.

    I hope that clarifies my request.
    • view 1 more comment
    • Right, but that is not what I am experiencing. I have a find query that uses a REST API to an Appery Database with hard coded parameters. The query runs immediately after the login. The query works in online mode, I use the client service to go into offline mode - return to the login page. When I login in offline mode their is no data. The only time it is different is if I use no parameters in the query.
    • Don't worry about it. I can get it to work using sever codes imported into API Express as Custom Services, and this allows me to include pointer fields and $inQueries as well.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Serhii, it turns out I still need to work through this. The API Express Find Service does not work offline when I query on a pointer column. I can get it to work on simple fields, online and offline. I can get it to work online on pointers, but when I use the exact same query on a pointer field offline then nothing gets returned. Is there a correct way to pass a pointer parameter so that the query works offline?
    • You are right, the offline mode works only with simple data formats, but doesn't work with pointers values. Do you need to filter data by related IDs or another parameters? If you need to filter them using IDs only, please add one more column to the collection wit ha type = string ad save here an ID, the same as you use in the pointer
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated