darthwesker / react-admin-loopback Goto Github PK
View Code? Open in Web Editor NEWPackages related to using Loopback with react-admin
License: MIT License
Packages related to using Loopback with react-admin
License: MIT License
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)
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?
Is there any plan to support loopback 4? I am interested to contribute if there is not project jet.
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.
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??
Related with:
loopback-content-range: issue #4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.