- Is there a tutorial which I can refer for DB array to local storage and vice versa? 2. Also, any tutorial on executing various update methods possible on an array - like put, post, patch etc?
Hi Anil,
Please check this thread:
https://getsatisfaction.com/apperyio/...
Hi Katya,
I am using the following code in a response mapping of a query service:
localStorage.setItem("Packs_LS", JSON.stringify(value));
var arrayFromLS = JSON.parse(localStorage.Packs_LS);
In above code, Packs_LS is local storage variable and value corresponds to a record within a DB array called Packs.
Since the response mapping gives a loop on all the records of DB array Packs, the above code leaves me with only the last record from Packs into Packs_LS.
How can I get the whole of Packs into Packs_LS? Do I need to change the place of writing JS (i.e. not in response mapping) or is there a way to accumulate all array records within mapping JS itself?
Anil,
On the event success of the service, the whole response is available at variable data. Thus, the entire array Packs will be available on data.Packs.
So add the event handler for success of the service of data read:
prelocalStorage.setItem("Packs_LS", data.Packs);/pre
And you should remove that code from the mapping
The above code in response mapping helps me display data in a grid.
I think even if I incorporate your suggestion above on the success of service, I would still need the JS code in response mapping for display purposes. Pls correct me if I am wrong.
Currently the display is as in this earlier query https://getsatisfaction.com/apperyio/...
Main reason for using the above code on response mapping is that I get to access the image name column in the array and then able to find the path for the same using:
var imageURL = Apperyio("Offer_image").attr("src",Appery.getImagePath(arrayFromLS.image));
arrayFromLS is a local array variable. Offer_image is the name of image component.
Is there another way of accessing the image name without using a local array variable? I am thinking more like the following. Pls correct me if the below code is not fully correct.
var imageURL = Apperyio("Offer_image").attr("src",Appery.getImagePath(value.image));
Hi Evgene, before I discuss fetching image URL further, wanted to give feedback on your earlier suggestion on using data.Packs.
I am using query service (not read service). Thus when I use your suggestion at service success, it gives me undefined value in Packs_LS. How do I get this right if I am using query service?
Even on using read service, Packs_LS final value shows as [object Object],[object Object]
Packs in my collection is a column of type array. I am trying to fetch one of the array records in Packs column which corresponds to a particular id in read service.
It's not sorted yet.
Hi Anil,
Regarding data.Packs: You can see in debugger what 'data' object is, probably it has a different structure: http://devcenter.appery.io/documentat...
Yes, you can set image in Image component via mapping, instead of using a variable with an array.
You can use the code that you provided above if service returns names of files stored in the app:preApperyio("Offer_image").attr("src",Appery.getImagePath(value.image));/pre
Could you please clarify whether you need to get a file link or an image file name?
Hi katya, my query regarding image has been solved. But for clarity, could u pls confirm if 'data' object is also available on success of a query service? Or is it available only on success of a read service?