Extending Storage Array variables in Apperyio project.

Problem:

Sometimes during working with Appery Storage you may face problem to add a new item or remove an item from array variable.

Solution:

Below are 3 small functions, which extends each array storage variable with push, pop and sort functions that you have in your project automatically on app launch.

Couple of functions which will help to work with array storage variables
Basic description:
push(newItem) – adds new value to array’s storage variable
pop(index|object) – removes value from array’s storage variable
sort(param, asc|desc) – sorts existing array by specified parameter, by default sorts by time if available.

Don’t forget, that functions extends Appery storage variable, so the actuall call should like:

Current version can be found in Github repo.

Here is an example of how it can be used:
1. Create a new object variable “newvar” in Model and an Array variable based on the 1st one “newvararry”.
new variables in Apperyio Model

2. Create new variable based “newvar”
new variable Apperyio Storage

3. Create new javascript file in your project and paste all from github apperyHelper.js file inside new javascript file.

4. Click test
5. Open Developer Tools in your browser and add fill your array variable with data

6. Call some functions from the helper like push, pop or sort. I will use sort as an example:

Here what should see in the console after calling any function:
testing helper functions

Just in case code attached here, but more actuallized version is no GitHub:

Leave a Reply

Your email address will not be published. Required fields are marked *