Как я могу обновить вложенный массив с хранилищем ionic4 - PullRequest
0 голосов
/ 09 октября 2019

Используя

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);     
  });
}

Я могу просмотреть свои сохраненные элементы пары ключ-значение в sqlite. Вот фото из console.log

console.log of db

Возможно ли обновить только массив сайтов с помощью

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

без удаления всех других массивов?

1 Ответ

0 голосов
/ 09 октября 2019

Мой асинхронный saveFormUpdates () был неправильным. Оказывается, просто сохранив this.audit вместо this.auditOne сделал все без дополнительной информации от меня.

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