Skip to content
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

feat(populate): ordered data from populate #180

Open
nemo opened this issue Feb 21, 2019 · 4 comments
Open

feat(populate): ordered data from populate #180

nemo opened this issue Feb 21, 2019 · 4 comments

Comments

@nemo
Copy link
Contributor

nemo commented Feb 21, 2019

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

Bug

What is the current behavior?

ordered data isn't populated

What is the expected behavior?

oredered data to be populated.

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

Never worked.

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

Populate a collection and look at state.firestore.ordered.

@prescottprue
Copy link
Owner

@nemo This is an extremely general bug description, and I don't believe I am understanding. Data is not ever populated within state, it is populated as you get it out of state using populate. Could you provide more description of what you are trying to accomplish as well as some code to reproduce (including version of dependencies)?

@nemo
Copy link
Contributor Author

nemo commented Mar 4, 2019

So in this scenario, I would expect _venue on the poets collection to be populated:

const PoetsList = compose(
  firestoreConnect((props, state) => [
    {
      collection: 'poets',
      orderBy: ['name'],
      limit: 1000,
      populates: [{ child: '_venue', root: 'venues' }],
      storeAs: 'orderedPoets'
    }
  ]),
  connect((state, props) => ({
    poets: state.firestore.ordered.orderedPoets || []
  }))
)(Poets)

However – it's not, because I can't use the populate function (like below) to populate the ordered version of the query results. But the following scenario works (since we can use populate, but obviously we lose the order):

const PoetsList = compose(
  firestoreConnect((props, state) => [
    {
      collection: 'poets',
      orderBy: ['name'],
      limit: 1000,
      populates: [{ child: '_venue', root: 'venues' }],
      storeAs: 'orderedPoets'
    }
  ]),
  connect((state, props) => ({
    poets: populate(state.firestore, 'orderedPoets', [{ child: '_venue', root: 'venues' }])
  }))
)(Poets)

Does that make sense? Or maybe I just don't know how to use populate with the ordered data state.

@prescottprue
Copy link
Owner

@nemo As you show in the second example there, you need to use populate to get populated data out. It does not currently support ordered data. Since the data needed to do the population is queried for by placing populates on the query setting, you can build the populated result manually from data out of state.

That said, it would be good to support ordered population, so lets have this ticket be a tracking of that feature 😄

@prescottprue prescottprue changed the title population doesn't populate ordered data Mar 4, 2019
@prescottprue prescottprue changed the title feat(helpers): ordered data from populate Mar 4, 2019
@nemo
Copy link
Contributor Author

nemo commented Mar 4, 2019

Yes – that's really what I've been trying to say, but utterly failing at it. I want populate to support ordered population :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants