Dynamoid
Dynamoid copied to clipboard
Indexes work only when the table has id field
Index work fine only when the HASH KEY is id.
In my opinion, indexes should not map obj.id
but [HASH_KEY, RANGE_VALUE] and use it as an identifier for the row the index is added to. This will make it easy to retrieve the item from the original table this way.
So I think the problem here is that on tables with range keys, the 'id' is still only the hash_key. This violates an implied identity:
x = MyTable.create
MyTable.find(x.id) == x ##Broken for tables with range keys
I think the fix is to enhance the id method to return the [hash_key, range_key] tuple, either as a string or as an actual array, though I haven't thought it all the way through.
Yes, my fix is a temporary fix, but at least it will partially work when there is no range_key. Changing it to [hash_key, range_key] has a lot of implies in the code and the way data is processed when retrieved from Adapter.