Skip to content

feat(query): populate document reference or computed child key #196

Open
@amitava82

Description

What is the feature?
My document looks like this

# /version/1/cookList/1
{
"name": "Foo",
 "cook": "/version/1/cook/FJp534F4DegCxOW9y2Os"
}

I want to populate cook whose value is full document path and not just ID. I tried something like this after going though few other issues but it did not work.

const populates = (dataKey, originalData) => {
  if (originalData && originalData['cook'] && !originalData['cookData']) {
    originalData['cookData'] = originalData.cook.split('/')[4];
  }
  return [{child: 'ownerData', root: 'version/1/cook'}]
};

const enhance = compose(
  firestoreConnect([
    { collection: '/version/1/cookList', storeAs: 'cooklist', populates }
  ]),
  connect(({ firestore }) => ({
    cooklist: populate(firestore, 'cooklist', populates)
  }))
);

What version would this apply to?
latest

Activity

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

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions