Updating an item logs correct, but old value persist
I'm trying to update the value of my Dexie Db however the old value persist.
This is from the parent component.
async onEdited(tagItem: TagItem) {
console.log("Id: " + tagItem.selection); // logs new value
this.updateItem(tagItem);
}
async updateItem(tagItem: TagItem) {
console.log("Id: " + tagItem.id); // logs correctly
console.log("Id: " + tagItem.selection); // logs new value
await db.TagItem.update(tagItem.id, {
tags: tagItem.tags,
Selection: tagItem.selection,
isFlipped: tagItem.isFlipped,
});
// Get the updated item from the database
const updatedItem = await db.TagItem.get(tagItem.id);
console.log("Updated item: " + updatedItem?.selection); // logs old value
}
I'm using the updateItem method in other functions as well, for updating other properties and then they update. But not in this function and I do not know why.
Let me know if I should post the templateUrl or other information. But since it logs correctly in the onEdited function, I really have no idea why this does not work.
I have tried skipping the async and await. Also tried with
setTimeout(() => {
this.updateItem(TagItem);
}, 500);