Dealing with SQLStorage and arrays


I’m learning Ionic’s 2 basics and I’m stuck with the SQLStorage system.

To put you in the context, I’m doing a todo app, so I store my elements in an array, I’m abble to save them without problem, but how could I delete or even edit them? When an item is added, I’m pushing it’s content (title + description) to my items array and then, I’m saving it with

let nData= JSON.stringify(data); // Where data is my items array'todos', nData);

My array is formated as this:
this.items = [ {title: 'title 1', description: 'blablabla 1'}, {title: 'title 2', description: 'blablabla 2'}, {title: 'title 3', description: 'blablabla 3'}, ];

For example, is there a way to edit/delete only the second element? I think my saving part is ok, all the work have to be done on the array and only then, call again the saving callback.


I’ve found the solution.

changeTitle = function(oldTitle, newTitle) {
	   for (var i in this.items) {
	     if (this.items[i].title == oldTitle) {
	        this.items[i].title = newTitle;;

To delete, use the same code but use the javascript’s slice function.