-
-
Notifications
You must be signed in to change notification settings - Fork 628
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
orderBy silently creating a collection with unique keys #1957
Comments
orderBy is basically iterating the index. But it sounds like the unique flag is set on the collection when you do the ordering. Try whether the call to eachUniqueKey() could be done on another collection instance to not affect the one you do orderBy on. I think the problem city could be the collection instance being reused |
Interesting. Okay, I'll give it a try. I quickly implemented the workaround mentioned above, removing orderBy and writing my own de-duping function for collection.each(). But I'll check out using a different collection instance. |
I have a table full of board games owned by my friends and details about them. The primary key for the table is a collection ID that is unique to each copy. There is also an objectId that correlates to the game, that is indexed.
Some versions of the same game have different names. For example, Carabande (a game where you flick disks around a racetrack) is also called PitchCar, but they share the same objectId -- they are two different names for the same game.
When I order the table by objectId,
orderBy
is quietly creating a collection that only has one document per objectId. A subsequentfilter
looks for a portion of a game title, and PitchCar is completely missing. It's not even in the collection to be found.orderBy
selected the document for Carabande to represent that objectId.I can order by the primary key as a workaround, but then I lose the ability to use
eachUniqueKey
later. I could write my owncollection.each
function that removes duplicates, but it feels likeorderBy
is doing more work than it should be.The text was updated successfully, but these errors were encountered: