Giter VIP home page Giter VIP logo

aor-postgrest-client's Introduction

postgREST Client for admin-on-rest

For using postgREST with admin-on-rest, use the postgrestClient function to convert AOR's REST dialect into one compatible with postgREST.

Installation

npm install aor-postgrest-client --save

Usage

See the example in App.js.example

// in src/App.js
import React from 'react';
import { Admin, Resource } from 'react-admin';
import postgrestClient from 'aor-postgrest-client';
import { List, Datagrid, TextField, NumberField } from 'react-admin';

import { ShowButton, EditButton, Edit, SimpleForm, DisabledInput, TextInput, NumberInput } from 'react-admin';
import { Create} from 'react-admin';
import { Show, SimpleShowLayout } from 'react-admin';

const BookList = (props) => (
    <List {...props}>
        <Datagrid>
            <ShowButton />
            <EditButton />
            <TextField source="author" />
            <NumberField source="count" />
        </Datagrid>
    </List>
);
export const BookShow = (props) => (
    <Show {...props}>
        <SimpleShowLayout>
            <TextField source="author" />
            <NumberField source="count" />
        </SimpleShowLayout>
    </Show>
);
export const BookEdit = (props) => (
    <Edit {...props}>
        <SimpleForm>
            <DisabledInput source="id" />
            <TextInput source="author" />
            <NumberInput source="count" />
        </SimpleForm>
    </Edit>
);
export const BookCreate = (props) => (
    <Create {...props}>
        <SimpleForm>
            <TextInput source="author" />
            <NumberInput source="count" />
        </SimpleForm>
    </Create>
);
const App = () => (
    <Admin dataProvider={postgrestClient('http://localhost:3000')}>
        <Resource name="books" show={BookShow} create={BookCreate} edit={BookEdit} list={BookList} />
    </Admin>
);

export default App;

License

This library is licensed under the MIT Licence, and sponsored by tomberek.

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.