Closed aretrace closed 1 year ago
Something about your description doesn't sound quite right (taking a new, higher Id before then re-using previous Ids). But anyway, that's not necessary to resolve in the context of your overall requirement, which, as I understand it, is simply to have no Id reuse at all - and just increment where you can.
TinyBase goes to some effort to reuse Ids (so that high frequency add/remove operations don't run out of Ids) but I don't mind exploring a new flag on those methods that disables reuse. Would that work?
And thanks for reporting and using TinyBase! Hope it's working out for you otherwise.
OK, this is enabled in v3.1.1.
It adds a reuseRowIds
parameter to the addRow method and the useAddRowCallback hook. It defaults to true, for backwards compatibility, but if set to false, new Row Ids will not be reused unless the whole Table is deleted.
Is your feature request related to a problem? Please describe. When adding rows with
store.addRow()
oruseRowCallback()
after removing rows in reverse order (based on sorted row IDs), the row IDs do not increment continuously. Instead, the first added row ID is one greater than the previous greatest ID, and subsequent row IDs decrease until they form a continuous sequence from 0 to the first incremented ID after row removals.Describe the solution you'd like Ensure that the row IDs generated by
store.addRow()
anduseRowCallback()
always increment based on the current greatest ID value.Describe alternatives you've considered As changing the behavior of
store.addRow()
anduseRowCallback()
could affect existing implementations, consider introducing a new method,store.appendRow()
, that generates auto-incrementing row IDs based on the current greatest ID value. This new method would provide a more intuitive and expected behavior without disrupting existing code that relies on the current behavior.