Hello guys,
I’m trying to save several data array object to sqlite storage.
I can manage to save just one but whenever I try to save another one, it overrides previous one with the same key name. I have to make the key value dynamic. How can I do that?
Here’s my data provider ts file.
private options: any[] = [
{
"name": "option 01",
"website": "www.google.com",
"about": "choose this option 01",
"id": "1"
},
{
"name": "option 02",
"website": "www.yahoo.com",
"about": "choose this option 02",
"id": "2"
},
{
"name": "option 03",
"website": "www.bing.com",
"about": "choose this option 03",
"id": "3"
},
{
"name": "option 04",
"website": "www.stackoverflow.com",
"about": "choose this option 04",
"id": "4"
}
]
and here’s my home.ts file. It saves data object well but right now, it can save only one.
I want to be able to save several and delete each dynamically using different key value per a data object.
setValue(){
this.storage.set("object",this.option).then((successData)=>{
console.log("Data Stored!");
console.log(successData);
})
}
getValue(){
this.storage.get("object").then((data)=>{
console.log(data);
})
}
removeValue() {
this.storage.remove("object").then((data)=> {
console.log("data removed!");
})
}
Thanks in advance, Ideally, I’m looking into save several data objects into the same key value with different ids… but unfortunately, if a key value is same, it will override the previous data object.
or is there any way to use data object’s name as key value?
For instance, I would like to use {{ option.name }} as unique key value for data object so I can later easily erase it too.