I'm trying to take an existing image, blob it, and then with associated data, store it to dexie. I've read the post here and the linked doc here, but it results in the error.
Anyway, I think this is the code in question because when I comment out the reference to it, everything goes back to normal.
dexDB.version(1).stores({
images: 'id, added, carousel, gallery, height, index, now, title, url, width, ',
})
export async function downloadAndStoreImage(img: Image) {
try {
const res = await fetch(img.url)
const blob = await res.blob()
// Store the binary data in indexedDB:
await dexDB.dexImages.put({ ...img, blob })
} catch (error) {
console.error(`LOG..error`, error)
}
}
As you can see, the index should be id
field (it's a hash from firebase), and it's defined in the schema, yet I get this error.
Any ideas how to clear up the error message?
I had the same Error and found out, it's a Typo.
The defined fields in the schema are fields that you can index and search for. That's why it says that index must have a name and can't be empty.
In your schema, you left a comma at the end.
...title, url, width, ',
Because of that, Dexie thinks you want another Index after width
.
Remove the comma and it should work.