You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const db = new Dexie("2f7b182a-672d-424d-a66a-84e835e522a3");
db.version(1).stores({
things: "++id, colour, [colour+number], [colour+id], [colour+id+number]",
});
OK: A liveQuery that does a simple toArray() on the things table auto-updates when a new item is added to things
OK: A liveQuery that does orderBy("colour").toArray() auto-updates
OK: A liveQuery that does orderBy("[colour+number]") auto-updates
Fail: A liveQuery that does orderBy("[colour+id]")does not auto-update
Fail: A liveQuery that does orderBy("[colour+id+number]")does not auto-update
This reproduces under 4.0.1. I was also seeing symptoms of it from a recent release of 3, from which I updated to 4 hoping it would be resolved. When it wasn't I put the rough but honest codesandbox reproducer together.
Am I doing something wrong? Or is there a bug with the auto-updating of liveQuery, perhaps when the PK and/or an auto-incremented index is involved in a compound index?
I had a quick look and I couldn't find an existing issue for this.
The text was updated successfully, but these errors were encountered:
For a table where I have a need for a certain seldomly-touched subset of fields, and where I want liveQuery to rerender only upon a change to those fields OR upon a new row in the table, I'm doing a liveQuery on:
(I happen to want the results ordered by orderIndex anyway, which is a number field I maintain and which I diligently ensure is distinct across all the rows)
Of course, this requires an additional compound index on the table, but I figured that's cheaper than any alternative that I know of.
My question is: If I'm scared of useMemo(), is that pattern still a clean and cheap way to limit the rerenders from useLiveQuery ? Is there a better way these days?
As an aside to the aside, my fear of useMemo() is that I expect that for every, say, 100 updates to the table in question, only 1 update is going to be the addition of a new row or the mutation of one of the "interesting" subset of fields. I figured liveQuery() would be unnecessarily spamming my component with 99 re-renders for every update that this component actually cares about, causing unnecessary work in considering the memo cache etc.
Demo: https://codesandbox.io/p/sandbox/zealous-mopsa-9qx3vp
Take for example:
liveQuery
that does a simpletoArray()
on thethings
table auto-updates when a new item is added tothings
liveQuery
that doesorderBy("colour").toArray()
auto-updatesliveQuery
that doesorderBy("[colour+number]")
auto-updatesliveQuery
that doesorderBy("[colour+id]")
does not auto-updateliveQuery
that doesorderBy("[colour+id+number]")
does not auto-updateThis reproduces under 4.0.1. I was also seeing symptoms of it from a recent release of 3, from which I updated to 4 hoping it would be resolved. When it wasn't I put the rough but honest codesandbox reproducer together.
Am I doing something wrong? Or is there a bug with the auto-updating of
liveQuery
, perhaps when the PK and/or an auto-incremented index is involved in a compound index?I had a quick look and I couldn't find an existing issue for this.
The text was updated successfully, but these errors were encountered: