question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(reducers): subcollection orderBy ordered array not correctly sorted after update

See original GitHub issue

Do you want to request a feature or report a bug?

bug

What is the current behavior?

Updating a field of a document in a subcollection, does update correctly the value of the document but not the array sorting. Refreshing returns the correct sorted array.

What is the expected behavior?

The array should be sorted correctly to the current values of the documents in the subcollection.

Which versions of dependencies, and which browser are affected by this issue? Did this work in previous versions or setups?

 "firebase": "^5.3.0",
 "react-redux": "^5.0.7",
 "react-redux-firebase": "^2.1.6",
 "redux-firestore": "^0.5.7"

browser independant

Steps to reproduce and if possible a minimal demo of the problem via codesandbox or similar.

Not sure, another issue might be related to this issue, but I will show the code for my specific problem.

firestore index is created for the query:

participants | points DESC wins DESC quotient DESC

connect listeners:

firestoreConnect((props) => [
    {
      collection: 'tournaments',
      doc: props.tournamentId,
      subcollections: [{ collection: 'participants' }],
      orderBy: [['points', 'desc'],['wins', 'desc'],['quotient', 'desc']],
      storeAs: 'participants' + props.tournamentId }
  ]),
 connect(
    ({ firestore }, props) =>  ({
        participants: firestore.ordered['participants' + props.tournamentId],
      )
    }
  )

If for example points are updated, the points are changed correctly in the array but the array is not correctly sorted due to the update. But participants are correctly sorted after each refresh/tab switch of the component.

There could be an easy solution for my problem, which I am currently cannot find or my expected behavior isn’t implemented yet.

Thanks for help!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Anne-Anqcommented, Sep 19, 2019

Hi @prescottprue,

In one listener response where I get a collection (ordered, filtered with a where and stored as something) I get:

  • some duplicate values in firestore.ordered.
  • some missing values in firestore.ordered. I get the same number of documents in firestore.ordered and in firestore.data, but firestore.ordered does not contain all the docs that are in firestore.data and it also contains some doubles. It is not a duplicate listener since that comes in only one listener response.

I believe this could be related to that issue.

1reaction
Anne-Anqcommented, Sep 20, 2019

I was wrong, I am not using orderBy in this case.

This is my listener: listenEvents: ({ firestore, teamId }) => date => { firestore.setListener({ collection: Team.collection, doc: teamId, subcollections: [{ collection: 'events' }], where: ['END_TIME', '>=', date], storeAs: 'events' }) }

I am using “redux-firestore”: “^0.7.0”

I am not sure how to help you replicate it, because we are using similar listeners and firestore.ordered in other places that work just fine.

Also the issue is there on first load: the first listener response is wrong as explained before, but if I change a document, in some cases, the document_modified changes the modified doc in firestore.ordered AND adds another one.

Is it the first time you here about that kind of issue? Let me know if there is anything in particular that you think would be helpful I shared

Read more comments on GitHub >

github_iconTop Results From Across the Web

bug(reducers): subcollection orderBy ordered array not correctly ...
bug (reducers): subcollection orderBy ordered array not correctly sorted after update.
Read more >
firestore orderby on subproperty (subcollection) - Stack Overflow
According to the documentation, I can order and limit my query in order to filter data based on a where clause. How can...
Read more >
API Changelog | Google Earth Engine
BACKWARD INCOMPATIBLE Changed Export logic in the Code Editor to no longer use the map bounds as a default region for the output....
Read more >
clojure.core - Clojure v1.11 API documentation
Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a clone of a,...
Read more >
Collections and Data Structures - Julia Documentation
Given the type of an iterator, return one of the following values: EltypeUnknown() if the type of elements yielded by the iterator is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found