tomberek / aor-postgrest-client Goto Github PK
View Code? Open in Web Editor NEWpostREST client for admin-on-rest
License: MIT License
postREST client for admin-on-rest
License: MIT License
I'm using create-react-app
for bootstrapping my application and it fails to build when this package is added. Here is what they say in docs:
The future release of admin-on-rest changes the expected format for REST responses (see https://github.com/marmelab/admin-on-rest/pull/385). It should be released within 2 weeks.
You need to release a new major version of aor-postgrest-client to take this change into account.
aor-postgrest-client/src/index.js
Line 35 in bb78191
For some reason, semicolons are replaced from the search field. This is a problem when you want to create a search-by-mac-address field for example.
A few weeks back I upgraded from admin-on-rest to react-admin. I had to change a few things to this postgrest client in order for it to be compatible with react-admin.
Care to copy this repo into tomberek/ra-postgrest-client
?
Afterwards, I will propose some PR's to it with the changes I had to make.
Im looking forward to using this client with admin-on-rest 0.7.2 version
I'm on Fedora 25 x86_64 with npm 3.10.10 and node 6.9.4
My sec/App.js looks like -
// in src/App.js
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import postgrestClient from 'aor-postgrest-client';
import { CityList } from './geo_city';
const App = () => (
<Admin restClient={postgrestClient('http://localhost:3000')}>
<Resource name="geo_city" list={CityList} />
</Admin>
);
export default App;
and I get
Failed to compile.
Error in ./src/App.js
Module not found: 'aor-postgrest-client' in /home/xxx/src/test-admin/test-admin/src
@ ./src/App.js 14:26-57
aor-postgrest-client
is installed in node_modules/aor-postgrest-client/
Whenever I try to use react-admin's ReferenceField
component, the client logs the error below:
"Cannot read property 'data' of undefined"
Is this feature not implemented yet & if not, is this something you're wanting a developer to work on to submit a PR?
Hello, I'm trying to get "ra-postgrest-clien" to work, which I installed by https://www.npmjs.com/package/ra-postgrest-client, but I'm returning the error: index.js: 1375 Warning: Missing translation for key: "Can not read property 'length' of null"
How can you solve it?
Tks!!!!
PostgREST expects braces around the list of ids even if it's only one (eg. "id=in.(1)"). Currently "convertRESTRequestToHTTP" creates a request without the braces. Hence, PostgREST returns an error.
Here's the fix:
case _reactAdmin.GET_MANY:
{
url = apiUrl + '/' + resource + '?id=in.(' + params.ids.join(',') + ')';
break;
}
Front end dev here feeling a bit out of my depth, but...Postgrest
appears to support a syntax to join or get values from the matching foreign key. I'm using a nice app on desktop called Postico which allows you to lookup the foreign key values (and filter on them in the paid version).
Postgrest docs example:
GET /films?select=title,directors(id,last_name)
If I am for instance building a plant database, I have a plant_table
with a row of Broccoli of ID 5
which belongs to plant family of Brassicas
(ID: 1
), when I create or edit this plant I would like to be able to type in "br" and see Brassicas listed, which once selected maps to the correct foreign key of ID: 1
.
The following works, obviously:
export const PlantEdit = (props) => (
<Edit {...props}>
<SimpleForm>
<TextInput source="name" />
<NumberInput source="plant_family_f" />
</SimpleForm>
</Edit>
);
This doesn't work, for various reasons.
export const PlantEdit = (props) => (
<Edit {...props}>
<SimpleForm>
<TextInput source="name" />
<AutocompleteInput source="plant_family_f" options="plant_family_f(id,name)"/>
</SimpleForm>
</Edit>
);
Is what I'm trying to do possible out of the box, or am I going to have to maintain a separate dictionary for the foreign key values or something in my front end code?
When using admin-on-rest 1.3.2 with this package, it causes admin-on-rest@^0.7.0 to be loaded with an older, conflicting version of React. This prevents the app from starting.
This does not apply to current trunk, which does not support the new REST response format, but it will once #2 is fixed -- possibly by accepting PR #3.
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.