简体   繁体   中英

How can I update a nested array with ionic4 storage

Using

openSavedForm() {
  this.storage.get('test').then((val) => {
    this.auditResults = JSON.parse(val);
    this.audit = this.auditResults
    this.auditOne = this.auditResults.siteVehicle; 
    console.log('pull all', this.audit);     
  });
}

I can view my key value pair stored items in sqlite. Here is a photo of the of the console.log

数据库的console.log

Is it possible to only update only the siteVehicle Array with

async saveFormUpdates() {
  this.newAudit =this.auditOne;
  await this.storage.set( 'test', JSON.stringify(this.newAudit));
  console.log ("storage", this.newAudit);
} 

with out deleting all the other arrays?

My async saveFormUpdates() was wrong. Turns out just saving this.audit instead of this.auditOne did everything with no further input from me.

async saveFormUpdates() {
 this.newAudit = this.audit;
 await this.storage.set( 'test', JSON.stringify(this.newAudit));
 console.log ("storage", this.newAudit);
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM