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.

Filter doesn't work with nested objects (Firestore maps)

See original GitHub issue

react-admin has the ability to use a reference to a Firestore map by using something like: <TextField source="author.firstName" /> (as briefly documented in the docs). or <ReferenceField label="Organization" source="organization.id" reference="organizations">

When trying to do this with a filter, it doesn’t work.

const ProgramFilter = (props) => (
  <Filter {...props}>
    <ReferenceInput label="Organization" source="organization.id" reference="organizations" allowEmpty>
      <SelectInput optionText="name" />
    </ReferenceInput>
  </Filter>
);

This is the URL that’s generated when the above filter is applied:

http://localhost:3000/programs?filter=%7B%22organization%22%3A%7B%22id%22%3A%22ZxaE6XPDbMQWkeADrUYs%22%7D%7D&order=ASC&page=1&perPage=10&sort=id

And the decoded version:

http://localhost:3000/programs?filter={"organization":{"id":"ZxaE6XPDbMQWkeADrUYs"}}&order=ASC&page=1&perPage=10&sort=id

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
davidstackiocommented, Apr 26, 2020

@benwinding That works. As always, thanks for your help!

1reaction
benwindingcommented, Apr 25, 2020

Hi @dhstack,

Hopefully this fixes the problem for using nested filters. It accesses the deep object field using dot path notation, like you mentioned above:

filter={{ 'organization.id': organizationId }}

Should be deployed in version 3.1.15

Here’s the unit-tests for it, let me know if this works for you:

https://github.com/benwinding/react-admin-firebase/blob/cd2a6842e2d8bdb76cb057eba4e06e387944e88e/tests/arrayHelpers.filtering.spec.ts#L92-L102

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to query nested objects in firestore - Stack Overflow
Since August 2018 there is the new array_contains operator which allows filtering based on array values.
Read more >
Add a Firestore document using a nested map | Google Cloud
To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser. Was this helpful?
Read more >
Reduce index costs with map fields | Firestore - Firebase
This page describes how to use a map field to manage index settings for a group of subfields. As a best practice, you...
Read more >
Topics tagged map - AppGyver forums
Topic Replies Views Activity Embedded map view · Bug · map , marketplace 3 60 December 12, 2022 Embedded Map view crash · Bug ·...
Read more >
Cloud Firestore - React Native Firebase
Installation and getting started with Firestore. ... arrays (lists) and objects (maps) along with specific Cloud Firestore data such as Timestamps, ...
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