JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q35930F
  • License MIT

A LeanCloud data provider for react-admin.

Package Exports

  • ra-data-leancloud

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 (ra-data-leancloud) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ra-data-leancloud

npm version GitHub license

A LeanCloud data provider for react-admin.

Features

  • 支持 JavaScript 和 TypeScript
  • 支持内嵌查询

Installation

yarn add ra-data-leancloud

# or

npm i ra-data-leancloud --save

Usage

// App.jsx or App.tsx

import dataProvider from "ra-data-leancloud"
import AV from "leancloud-storage"

// init leancloud storage before use the data provider
AV.init({
  appId: "appId",
  appKey: "appKey"
})

dataProvider.init({ AV })

export default () => (
  <Admin dataProvider={dataProvider}>
    {/* name should be the class name in your leancloud storage service */}
    <Resource name="Todo" />
  </Admin>
)

内嵌查询:

// SomeList.jsx or SomeList.tsx

<List filter={{ "todo.folder": targetFolder }} />

Tips:

  • 内嵌查询有一定限制,详情查看 LeanCloud 官方说明
  • 内嵌查询可以有多个层级,如 a.b.c.d.e

Limitation

若要完整使用此 data provider 的功能,需要遵循以下命名习惯:

  • class 的名称为大驼峰式,如:TodoFolder
  • Pointer 类型的字段名称为小驼峰式,且拼写与指向的 class 名称相同,例如:字段 todoFolder -> class TodoFolder

如果不遵循此习惯,那么当请求中有对 Pointer 类型字段的操作时,可能会抛出错误。

Change Log

Please refer to CHANGELOG.md.

License

MIT.