-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create{Key/Read}Stream use the wrong keys #34
Comments
Looks like it’s working as intended. It looks like you are confusing how the underlying index db works and how the higher level index api is presenting that data. If you want you can hold reference to the level instance you pass in when creating the index, then create read streams off that. Don’t write to it though because you will bypass the lifecycle hooks. I would write an example but I’m mobile atm. I think there are tests on this as well but it’s been while since I wrote it. |
The index is generating key variances for various sorting and grouping properties. But it all points back to a master document. The high level api saves you the time of having to do the mapping yourself. You just read stream the indexed let’s but then always get back the correct documents. |
The documentation states Which behavior is the correct one is of course a matter of opinion with valid arguments for both sides. The documentation gives more intuitive streams considering that both borders ( In my specific scenario I have database-entries getting multiple index-entries, so knowing which index-key a specific occurence corresponds to is a very important part, so I did actually end up doing the mapping by hand. However if the behaviour is as intended or at least too much of a breaking change to modify, I would at least suggesting to change the documentation to be more clear about the behavior. Personally I would favor an option to switch between the two options. Would you be open to merging such a feature if I implemented it? |
Maybe we can add a third value like indexKey to createReadStream? Would that cut it? iirc I copied the original design from Julian Grubers module. |
Sure, that would also work nicely. Do you want to add it (should be |
You can add if your want. Otherwise I can try and take a look this week |
I have added an indexKey field and updated Readme and tests accordingly (#35 ). I haven't updated the changeglog though, since I assumed that you might want to update the dependencies in the same bumb. |
According to the documentation createKeyStream and createValueStream should use the indices as keys and the indexed values as values. However in reality it uses the keys of the original db on which the index has been created.
According to the documentation this code should output:
In reality it generates the following output:
The text was updated successfully, but these errors were encountered: