Giter VIP home page Giter VIP logo

react-admin-loopback's People

Contributors

afilp avatar darthwesker avatar imekinox avatar sghribi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-admin-loopback's Issues

GET_MANY fetch ALL data

In index.js, GET_MANY action is performed like this :

      case GET_MANY: {
        const query = {
          filter: JSON.stringify({ id: params.ids }),
        };
        url = `${apiUrl}/${resource}?${stringify(query)}`;
        break;
      }

I think it should be like this (https://github.com/kimkha/aor-loopback/blob/master/src/index.js#L55) :

            case GET_MANY: {
                const listId = params.ids.map(id => {
                    return {'id': id};
                });
                const query = {
                    'where': {'or': listId}
                };
                url = `${apiUrl}/${resource}?${queryParameters({filter: JSON.stringify(query)})}`;
                break;
            }

According to loopback documentation, the request is not correct : in the first case, ALL data are fetched (this is not normal), whereas is the second case, only selected data are fetched (that's what we want).

Does anyone agree? (I can make a PR to fix this)

GET_MANY

I have the following filter in react-admin:

<ReferenceArrayInput
        label="Departments"
        source="dept_id"
        reference="departments"
        allowEmpty
        perPage={1000}
        sort={{field: 'name', order: 'ASC'}}
        alwaysOn
        style={{
          minWidth: 150,
        }}
        filterToQuery={searchText => ({
          name: {
            "like": `.*${escapeRegExp(searchText)}.*`,
            "options": "i"
          }
        })}
      >
        <AutocompleteArrayInput />
      </ReferenceArrayInput>

When I choose a value and then remove it from the ArrayInput, I get the following error:

Unhandled error for request GET /api/departments?filter=%7B%22where%22%3A%7B%22or%22%3A%5B%5D%7D%7D: MongoError: $and/$or/$nor must be a nonempty array

This is because the or below has an empty array (listId is []):

      case GET_MANY: {
        const listId = params.ids.map(id => {
          return {id};
        });
        const query = {
          where: {or: listId},
        };
        url = `${apiUrl}/${resource}?${stringify({filter: JSON.stringify(query)})}`;
        break;
      }

I think this is a bug and needs to be addressed?

Loopback 4

Is there any plan to support loopback 4? I am interested to contribute if there is not project jet.

Nested relationships

Doesn't work with / support nested resources,
e.g.
/parent/{id}/child/{id}
And similar API routes would just not work, would be cool to have this as a feature.

Include auth Token

If using loopback with ACLs how would you pass the localStorage session Token I can see the fetch.js trying but how is this invoked??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.