2

i have an object which gets updated when ever some data change occurs, i need to store the previous and updating data into an array and retrieve it when required

/* currently i could get 1 data i need multiple data stored to a storage as array*/
    get(){
        this.storage.get('uploaded').then((data) => {
            console.log("get data", JSON.parse(data));        
        });
    }

    set(){
        var obj = { upload: true,
                    file: file.audio //this will hold an object which vary when required
                  }

        this.storage.set('uploaded', JSON.stringify( obj ));
    }
3
  • Is file an array of a object ? i guess you need to make any array of files and do a push if you need to have multiple values Commented Mar 1, 2017 at 5:28
  • yes file is an object could u create me a sample Commented Mar 1, 2017 at 5:33
  • you got a simple by @rahul hope that helps Commented Mar 1, 2017 at 6:54

1 Answer 1

2

You could use the push() method of array to update the array with new data.

var obj = new Array();
obj.push();// use this whenever you have new data

and use this to access the values

for (var i in obj) {
   //access values using obj[i]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.