Package Exports
- moleculer-ra-data-provider
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (moleculer-ra-data-provider) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
moleculer-ra-data-provider
A Moleculer compatible data provider for React Admin.
Convert on-the-fly data exchanged with Moleculer micro-services in order to use them directly in your React-Admin components like List, Edit, Create ....
Features
Supported actions:
CREATEGET_ONEGET_LISTGET_MANYGET_MANY_REFERENCEUPDATEUPDATE_MANYDELETEDELETE_MANY
Installation
# via npm
npm install moleculer-ra-data-provider
# OR via yarn
yarn add moleculer-ra-data-providerUsage
Import this package, set the base url and pass it as the dataProvider to react-admin.
//in app.js
import React from "react";
import { Admin, Resource } from "react-admin";
import { ListGuesser } from 'react-admin'; // example
import moleculerDataProvider from 'moleculer-ra-data-provider';
const dataProvider = moleculerDataProvider('http://localhost:13000/api');
const App = () => (
<Admin dashboard={Dashboard} dataProvider={dataProvider}>
// example displaying a list received from http://localhost:3000/api/myusers
<Resource name="myusers" list={ListGuesser} />
</Admin>
);
export default App;Options
You can specify the _id field name (duplicated as id for react-admin) for some/all resources
Example 1: the moleculer service 'orders' is using uuid instead of _id
//in app.js
const dataProvider = moleculerDataProvider('http://localhost:13000/api', {idFields: {"orders": "uuid" }});Example 2: the moleculer service 'orders' is using uuid instead of _id, others are using myId
//in app.js
const dataProvider = moleculerDataProvider('http://localhost:13000/api', {idFields: {"orders": "uuid", "DEFAULT": "myId" }});Licence
MIT