@raphiniert/ra-data-postgrest 2.0.0-alpha.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,105 +2,163 @@
2
2
 
3
3
  Find all notable changes of this project in this file.
4
4
 
5
+ ## v2.0.0-alpha.1 - 2023-04-09
6
+ ### Improvements
7
+ - updated dependencies
8
+ - updated `urlBuilder` and integrated URL encoding
9
+
10
+ ### New feature
11
+ - [#48](https://github.com/raphiniert-com/ra-data-postgrest/issues/48) solved by pull request [#55](https://github.com/raphiniert-com/ra-data-postgrest/pull/55), the create method should return the data returned by postgrest and not the posted data - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
12
+ - [#39](https://github.com/raphiniert-com/ra-data-postgrest/pull/39), allow passing extra headers via meta for react-admin hooks - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
13
+ - [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41), allow columns filtering for getList and getManyReference - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
14
+ - added support of [#41](https://github.com/raphiniert-com/ra-data-postgrest/pull/41) for other functions, but `create` and `updateMany`
15
+ - [#38](https://github.com/raphiniert-com/ra-data-postgrest/pull/38), Let the sort param in getList be optional - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
16
+
17
+
18
+ ## v1.2.1 - 2023-04-07
19
+ - small fix in condition
20
+ - fixed package name
21
+
5
22
  ## v2.0.0-alpha.0 - 2022-11-23
6
- - [#42](https://github.com/raphiniert-com/ra-data-postgrest/issues/42), started adding some unit tests - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
7
- - dropped authProvider
8
- - code cleanup & restructuring
9
- - minor bugfixes - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
10
- - added some notes to README.md
23
+
24
+ - [#42](https://github.com/raphiniert-com/ra-data-postgrest/issues/42), started adding some unit tests - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
25
+ - dropped authProvider
26
+ - code cleanup & restructuring
27
+ - minor bugfixes - @[christiaanwesterbeek](https://github.com/christiaanwesterbeek)
28
+ - added some notes to README.md
11
29
 
12
30
  ### Breaking changes
13
- - dropped authProvider as this should rather be an own package in case of a generic piece of software or application specific.
31
+
32
+ - dropped authProvider as this should rather be an own package in case of a generic piece of software or application specific.
14
33
 
15
34
  ## v1.2.0 - 2022-08-23
16
- - [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), adding dependabot - @[promitheus7](https://github.com/promitheus7)
17
- - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30) and [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), updated dependency to compatible starting from `ra-core` 4.1.x - @[corrideat](https://github.com/corrideat), @[promitheus7](https://github.com/promitheus7)
35
+
36
+ - [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), adding dependabot - @[promitheus7](https://github.com/promitheus7)
37
+ - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30) and [#33](https://github.com/raphiniert-com/ra-data-postgrest/pull/33), updated dependency to compatible starting from `ra-core` 4.1.x - @[corrideat](https://github.com/corrideat), @[promitheus7](https://github.com/promitheus7)
18
38
 
19
39
  ## v1.1.9 - 2022-08-23
20
- - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30), updated ts and modified code, such that some package dependencies became unrequired - @[corrideat](https://github.com/corrideat)
40
+
41
+ - [#30](https://github.com/raphiniert-com/ra-data-postgrest/pull/30), updated ts and modified code, such that some package dependencies became unrequired - @[corrideat](https://github.com/corrideat)
21
42
 
22
43
  ## v1.1.8 - 2022-01-07
23
- - required re-release as I missed to transpile all and upload the features of 1.1.7 to npm.
44
+
45
+ - required re-release as I missed to transpile all and upload the features of 1.1.7 to npm.
24
46
 
25
47
  ## v1.1.7 - 2022-01-07
48
+
26
49
  ### Fixes
27
- - fixed bad behaivor with compound keys while using field named `id` [issue #27](https://github.com/raphiniert-com/ra-data-postgrest/issues/27) and [issue #19](https://github.com/raphiniert-com/ra-data-postgrest/pull/19) - @[kenfehling](https://github.com/kenfehling)
50
+
51
+ - fixed bad behaivor with compound keys while using field named `id` [issue #27](https://github.com/raphiniert-com/ra-data-postgrest/issues/27) and [issue #19](https://github.com/raphiniert-com/ra-data-postgrest/pull/19) - @[kenfehling](https://github.com/kenfehling)
28
52
 
29
53
  ### New feature
30
- - [#26](https://github.com/raphiniert-com/ra-data-postgrest/pull/26), added rpc filter support, which is explained [here](https://github.com/raphiniert-com/ra-data-postgrest#special-filter-feature-rpc-functions) - @[TheRealAstroboy](https://github.com/TheRealAstroboy)
31
54
 
55
+ - [#26](https://github.com/raphiniert-com/ra-data-postgrest/pull/26), added rpc filter support, which is explained [here](https://github.com/raphiniert-com/ra-data-postgrest#special-filter-feature-rpc-functions) - @[TheRealAstroboy](https://github.com/TheRealAstroboy)
32
56
 
33
57
  ## v1.1.6 - 2021-01-16
58
+
34
59
  ### Fixes
35
- - [#24](https://github.com/raphiniert-com/ra-data-postgrest/pull/24), fixed eq. prefix for non-compound keys [issue #23](https://github.com/raphiniert-com/ra-data-postgrest/issues/23) - @[andymed-jlp](https://github.com/andymed-jlp)
60
+
61
+ - [#24](https://github.com/raphiniert-com/ra-data-postgrest/pull/24), fixed eq. prefix for non-compound keys [issue #23](https://github.com/raphiniert-com/ra-data-postgrest/issues/23) - @[andymed-jlp](https://github.com/andymed-jlp)
36
62
 
37
63
  ## v1.1.5 - 2021-01-16
64
+
38
65
  ### Fixes
39
- - fixed query string generation of rpc endpoints [issue #22](https://github.com/raphiniert-com/ra-data-postgrest/issues/22)
66
+
67
+ - fixed query string generation of rpc endpoints [issue #22](https://github.com/raphiniert-com/ra-data-postgrest/issues/22)
40
68
 
41
69
  ### Breaking changes
42
- - Support was dropped for generating the query string given many ids in case of an rpc endpoint. If your application has some psql functions which parse the standard input, I recommend to rework your db design. If this change causes strong damage to your application, please contact me in order to find a proper generic solution. Query strings of single rpc calls now drop the operator (`eq.`) and are generated properly.
70
+
71
+ - Support was dropped for generating the query string given many ids in case of an rpc endpoint. If your application has some psql functions which parse the standard input, I recommend to rework your db design. If this change causes strong damage to your application, please contact me in order to find a proper generic solution. Query strings of single rpc calls now drop the operator (`eq.`) and are generated properly.
43
72
 
44
73
  ## v1.1.4 - 2021-01-16
45
- - deployment error
74
+
75
+ - deployment error
46
76
 
47
77
  ## v1.1.3 - 2020-11-30
78
+
48
79
  ### Fixes
49
- - [#20](https://github.com/raphiniert-com/ra-data-postgrest/pull/20), fixed small bug in update - @[mkkane](https://github.com/mkkane)
50
- - removed console log
80
+
81
+ - [#20](https://github.com/raphiniert-com/ra-data-postgrest/pull/20), fixed small bug in update - @[mkkane](https://github.com/mkkane)
82
+ - removed console log
51
83
 
52
84
  ## v1.1.2 - 2020-10-05
85
+
53
86
  ### Fixes
54
- - fixed the last fix of getMany and getManyReferecnce for compound keys :)
87
+
88
+ - fixed the last fix of getMany and getManyReferecnce for compound keys :)
55
89
 
56
90
  ## v1.1.1 - 2020-09-28
91
+
57
92
  ### Fixes
58
- - fixed getMany and getManyReferecnce for compound keys
93
+
94
+ - fixed getMany and getManyReferecnce for compound keys
59
95
 
60
96
  ## v1.1.0 - 2020-09-16
97
+
61
98
  ### Fixes
62
- - removed requirement to define order key in react admin, when using compound keys: default was `id`, now it's the compound key
99
+
100
+ - removed requirement to define order key in react admin, when using compound keys: default was `id`, now it's the compound key
63
101
 
64
102
  ### Breaking changes
65
- - refactored compound primary keys:
66
- For single custom keys wrap an array as follows:
67
- ```jsx
68
- const dataProvider = postgrestRestProvider(API_URL, fetchUtils.fetchJson, 'eq', new Map([
69
- ['some_table', ['custom_id']], // <- instead of ['some_table','custom_id']
70
- ['another_table', ['first_column', 'second_column']],
71
- ]));
72
- ```
103
+
104
+ - refactored compound primary keys:
105
+ For single custom keys wrap an array as follows:
106
+ ```jsx
107
+ const dataProvider = postgrestRestProvider(
108
+ API_URL,
109
+ fetchUtils.fetchJson,
110
+ 'eq',
111
+ new Map([
112
+ ['some_table', ['custom_id']], // <- instead of ['some_table','custom_id']
113
+ ['another_table', ['first_column', 'second_column']],
114
+ ])
115
+ );
116
+ ```
73
117
 
74
118
  ## v1.0.7 - 2020-08-23
119
+
75
120
  ### New feature
76
- - [#14](https://github.com/raphiniert-com/ra-data-postgrest/pull/14), added compound primary keys (see [README.md](https://github.com/raphiniert-com/ra-data-postgrest/blob/master/README.md#compound-primary-keys)) - @[programmarchy](https://github.com/programmarchy)
121
+
122
+ - [#14](https://github.com/raphiniert-com/ra-data-postgrest/pull/14), added compound primary keys (see [README.md](https://github.com/raphiniert-com/ra-data-postgrest/blob/master/README.md#compound-primary-keys)) - @[programmarchy](https://github.com/programmarchy)
77
123
 
78
124
  ### Maintenance
79
- - `import React from 'react';` -> `import * as React from 'react';`
80
- - Some minor code cleanup
125
+
126
+ - `import React from 'react';` -> `import * as React from 'react';`
127
+ - Some minor code cleanup
81
128
 
82
129
  ## v1.0.6 - 2020-06-15
130
+
83
131
  ### Fixes
84
- - Fixed wrong support statement concerning [postgrest starter kit](https://github.com/subzerocloud/postgrest-starter-kit) in readme
132
+
133
+ - Fixed wrong support statement concerning [postgrest starter kit](https://github.com/subzerocloud/postgrest-starter-kit) in readme
85
134
 
86
135
  ## v1.0.5 - 2020-06-15
136
+
87
137
  ### Fixes
88
- - [#13](https://github.com/raphiniert-com/ra-data-postgrest/pull/13), Remove console.log - @[jpagex](https://github.com/jpagex)
89
- - [#12](https://github.com/raphiniert-com/ra-data-postgrest/pull/12), Fixed limit parameter - @[jpagex](https://github.com/jpagex)
138
+
139
+ - [#13](https://github.com/raphiniert-com/ra-data-postgrest/pull/13), Remove console.log - @[jpagex](https://github.com/jpagex)
140
+ - [#12](https://github.com/raphiniert-com/ra-data-postgrest/pull/12), Fixed limit parameter - @[jpagex](https://github.com/jpagex)
90
141
 
91
142
  ## v1.0.4 - 2020-06-08
143
+
92
144
  ### Fixes
93
- - Fixed missing js files in npm package [#8](https://github.com/raphiniert-com/ra-data-postgrest/issues/8)
94
- - [#9](https://github.com/raphiniert-com/ra-data-postgrest/pull/9), Fixed typo in readme - @[seclace](https://github.com/seclace)
145
+
146
+ - Fixed missing js files in npm package [#8](https://github.com/raphiniert-com/ra-data-postgrest/issues/8)
147
+ - [#9](https://github.com/raphiniert-com/ra-data-postgrest/pull/9), Fixed typo in readme - @[seclace](https://github.com/seclace)
95
148
 
96
149
  ## v1.0.3 - 2020-05-17
150
+
97
151
  ### Fixes
98
- - Fixed bug when multidelete - @[colonist4096](https://github.com/colonist4096)
99
- - [#5](https://github.com/raphiniert-com/ra-data-postgrest/pull/6), Fixed bug while using multiple filters on the same attribute - @[olivierdalang](https://github.com/olivierdalang)
152
+
153
+ - Fixed bug when multidelete - @[colonist4096](https://github.com/colonist4096)
154
+ - [#5](https://github.com/raphiniert-com/ra-data-postgrest/pull/6), Fixed bug while using multiple filters on the same attribute - @[olivierdalang](https://github.com/olivierdalang)
100
155
 
101
156
  ## v1.0.2 - 2020-03-10
157
+
102
158
  ### Fixes
103
- - [#4](https://github.com/raphiniert-com/ra-data-postgrest/pull/4), Fixed bug while using ReferenceField with UUID - @[xero88](https://github.com/xero88)
159
+
160
+ - [#4](https://github.com/raphiniert-com/ra-data-postgrest/pull/4), Fixed bug while using ReferenceField with UUID - @[xero88](https://github.com/xero88)
104
161
 
105
162
  ## v1.0.1 - 2020-02-01
106
- - initial release
163
+
164
+ - initial release
package/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  # PostgREST Data Provider For React-Admin
2
+ [![npm](https://img.shields.io/npm/v/@raphiniert/ra-data-postgrest.svg)](https://www.npmjs.com/package/@raphiniert/ra-data-postgrest)
3
+ [![npm downloads](https://img.shields.io/npm/dm/@raphiniert/ra-data-postgrest.svg)](https://www.npmjs.com/package/@raphiniert/ra-data-postgrest)
4
+ [![Coverage Status](https://coveralls.io/repos/github/raphiniert-com/ra-data-postgrest/badge.svg?branch=master)](https://coveralls.io/github/raphiniert-com/ra-data-postgrest?branch=master)
5
+ [![License: MIT](https://img.shields.io/gitlab/license/24181795)](https://github.com/raphiniert-com/ra-data-postgrest/blob/master/LICENSE)
6
+
2
7
 
3
8
  PostgREST Data Provider for [react-admin](https://github.com/marmelab/react-admin), the frontend framework for building admin applications on top of REST/GraphQL services.
4
9
 
5
10
  ## Installation
6
11
 
7
12
  ```sh
8
- npm install --save @promitheus/ra-data-postgrest
13
+ npm install --save @raphiniert/ra-data-postgrest
9
14
  ```
10
15
 
11
16
  **NOTE**: When using RA 3.x.x, use the data-provider 1.x.x. For RA >= 4.1.x use the data-provider starting from 1.2.x.
@@ -14,17 +19,17 @@ npm install --save @promitheus/ra-data-postgrest
14
19
 
15
20
  This Data Provider fits REST APIs using simple GET parameters for filters and sorting. This is the dialect used for instance in [PostgREST](http://postgrest.org).
16
21
 
17
- | Method | API calls
18
- |--------------------|----------------------------------------------------------------
19
- | `getList` | `GET http://my.api.url/posts?order=title.asc&offset=0&limit=24&filterField=eq.value`
20
- | `getOne` | `GET http://my.api.url/posts?id=eq.123`
21
- | `getMany` | `GET http://my.api.url/posts?id=in.(123,456,789)`
22
- | `getManyReference` | `GET http://my.api.url/posts?author_id=eq.345`
23
- | `create` | `POST http://my.api.url/posts`
24
- | `update` | `PATCH http://my.api.url/posts?id=eq.123`
25
- | `updateMany` | `PATCH http://my.api.url/posts?id=in.(123,456,789)`
26
- | `delete` | `DELETE http://my.api.url/posts?id=eq.123`
27
- | `deleteMany` | `DELETE http://my.api.url/posts?id=in.(123,456,789)`
22
+ | Method | API calls |
23
+ | ------------------ | ------------------------------------------------------------------------------------ |
24
+ | `getList` | `GET http://my.api.url/posts?order=title.asc&offset=0&limit=24&filterField=eq.value` |
25
+ | `getOne` | `GET http://my.api.url/posts?id=eq.123` |
26
+ | `getMany` | `GET http://my.api.url/posts?id=in.(123,456,789)` |
27
+ | `getManyReference` | `GET http://my.api.url/posts?author_id=eq.345` |
28
+ | `create` | `POST http://my.api.url/posts` |
29
+ | `update` | `PATCH http://my.api.url/posts?id=eq.123` |
30
+ | `updateMany` | `PATCH http://my.api.url/posts?id=in.(123,456,789)` |
31
+ | `delete` | `DELETE http://my.api.url/posts?id=eq.123` |
32
+ | `deleteMany` | `DELETE http://my.api.url/posts?id=in.(123,456,789)` |
28
33
 
29
34
  **Note**: The PostgREST data provider expects the API to include a `Content-Range` header in the response to `getList` calls. The value must be the total number of resources in the collection. This allows react-admin to know how many pages of resources there are in total, and build the pagination controls.
30
35
 
@@ -44,7 +49,7 @@ Access-Control-Expose-Headers: Content-Range
44
49
  // in src/App.js
45
50
  import React from 'react';
46
51
  import { Admin, Resource } from 'react-admin';
47
- import postgrestRestProvider from '@promitheus/ra-data-postgrest';
52
+ import postgrestRestProvider from '@raphiniert/ra-data-postgrest';
48
53
 
49
54
  import { PostList } from './posts';
50
55
 
@@ -61,11 +66,11 @@ export default App;
61
66
 
62
67
  The provider function accepts an HTTP client function as second argument. By default, they use react-admin's `fetchUtils.fetchJson()` as HTTP client. It's similar to HTML5 `fetch()`, except it handles JSON decoding and HTTP error codes automatically.
63
68
 
64
- That means that if you need to add custom headers to your requests, you just need to *wrap* the `fetchJson()` call inside your own function:
69
+ That means that if you need to add custom headers to your requests, you just need to _wrap_ the `fetchJson()` call inside your own function:
65
70
 
66
71
  ```jsx
67
72
  import { fetchUtils, Admin, Resource } from 'react-admin';
68
- import postgrestRestProvider from '@promitheus/ra-data-postgrest';
73
+ import postgrestRestProvider from '@raphiniert/ra-data-postgrest';
69
74
 
70
75
  const httpClient = (url, options = {}) => {
71
76
  if (!options.headers) {
@@ -79,7 +84,7 @@ const dataProvider = postgrestRestProvider('http://localhost:3000', httpClient);
79
84
 
80
85
  render(
81
86
  <Admin dataProvider={dataProvider} title="Example Admin">
82
- ...
87
+ ...
83
88
  </Admin>,
84
89
  document.getElementById('root')
85
90
  );
@@ -93,7 +98,7 @@ Now all the requests to the REST API will contain the `X-Custom-Header: foobar`
93
98
  const httpClient = (url, options = {}) => {
94
99
  options.user = {
95
100
  authenticated: true,
96
- token: 'SRTRDFVESGNJYTUKTYTHRG'
101
+ token: 'SRTRDFVESGNJYTUKTYTHRG',
97
102
  };
98
103
  return fetchUtils.fetchJson(url, options);
99
104
  };
@@ -101,67 +106,94 @@ const httpClient = (url, options = {}) => {
101
106
 
102
107
  Now all the requests to the REST API will contain the `Authorization: SRTRDFVESGNJYTUKTYTHRG` header.
103
108
 
104
- ### Using authProvider
105
- This package also comes with an [authProvider](https://github.com/marmelab/react-admin/blob/master/docs/Authentication.md) for react-admin which enables you to enable authentification. The provider is designed to work together with [subzero-starter-kit](https://github.com/subzerocloud/subzero-starter-kit). This starter kit sends the JWT within a session cookie. The authProvider expects that. If you want to use postgREST without the starter kit you'll need to write your own. Feel free to contribute!
106
-
107
- With one of the starter kits it is very easy to use the authProvider:
108
- ```jsx
109
- // in src/App.js
110
- import React from 'react';
111
- import { Admin, Resource } from 'react-admin';
112
- import postgrestRestProvider, { authProvider } from '@promitheus/ra-data-postgrest';
113
-
114
- import { PostList } from './posts';
115
-
116
- const App = () => (
117
- <Admin dataProvider={postgrestRestProvider('http://path.to.my.api/')}
118
- authProvider={authProvider}>
119
- <Resource name="posts" list={PostList} />
120
- </Admin>
121
- );
122
-
123
- export default App;
124
- ```
125
-
126
109
  ### Special Filter Feature
127
- As postgRest allows several comparators, e.g. `ilike`, `like`, `eq`...
110
+
111
+ As postgRest allows several comparators, e.g. `ilike`, `like`, `eq`...
128
112
  The dataProvider is designed to enable you to specify the comparator in your react filter component:
129
113
 
130
114
  ```jsx
131
115
  <Filter {...props}>
132
- <TextInput label="Search" source="post_title@ilike" alwaysOn />
133
- <TextInput label="Search" source="post_author" alwaysOn />
134
- // some more filters
116
+ <TextInput label="Search" source="post_title@ilike" alwaysOn />
117
+ <TextInput label="Search" source="post_author" alwaysOn />
118
+ // some more filters
135
119
  </Filter>
136
120
  ```
137
121
 
138
122
  One can simply append the comparator with an `@` to the source. In this example the field `post_title` would be filtered with `ilike` whereas `post_author` would be filtered using `eq` which is the default if no special comparator is specified.
139
123
 
140
124
  #### RPC Functions
141
- Given a RPC call as ```GET /rpc/add_them?post_author=Herbert HTTP/1.1```, the dataProvider allows you to filter such endpoints. As they are no view, but a SQL procedure, several postgREST features do not apply. I.e. no comparators such as `ilike`, `like`, `eq` are applicable. Only the raw value without comparator needs to be send to the API. In order to realize this behavior, just add an "empty" comparator to the field, i.e. end `source` with an `@` as in the example:
125
+
126
+ Given a RPC call as `GET /rpc/add_them?post_author=Herbert HTTP/1.1`, the dataProvider allows you to filter such endpoints. As they are no view, but a SQL procedure, several postgREST features do not apply. I.e. no comparators such as `ilike`, `like`, `eq` are applicable. Only the raw value without comparator needs to be send to the API. In order to realize this behavior, just add an "empty" comparator to the field, i.e. end `source` with an `@` as in the example:
142
127
 
143
128
  ```jsx
144
129
  <Filter {...props}>
145
- <TextInput label="Search" source="post_author@" alwaysOn />
146
- // some more filters
130
+ <TextInput label="Search" source="post_author@" alwaysOn />
131
+ // some more filters
147
132
  </Filter>
148
133
  ```
149
134
 
150
135
  ### Compound primary keys
136
+
151
137
  If one has data resources without primary keys named `id`, one will have to define this specifically. Also, if there is a primary key, which is defined over multiple columns:
152
138
 
153
139
  ```jsx
154
- const dataProvider = postgrestRestProvider(API_URL, fetchUtils.fetchJson, 'eq', new Map([
155
- ['some_table', ['custom_id']],
156
- ['another_table', ['first_column', 'second_column']],
157
- ]));
140
+ const dataProvider = postgrestRestProvider(
141
+ API_URL,
142
+ fetchUtils.fetchJson,
143
+ 'eq',
144
+ new Map([
145
+ ['some_table', ['custom_id']],
146
+ ['another_table', ['first_column', 'second_column']],
147
+ ])
148
+ );
158
149
  ```
159
150
 
151
+ ### Passing extra headers via meta
152
+ Postgrest supports calling functions with a single JSON parameter by sending the header Prefer: params=single-object with your request according to its [docs](https://postgrest.org/en/stable/api.html#calling-functions-with-a-single-json-parameter).
153
+
154
+ Within the data provider one can add any kind of header to the request while calling react-admin hooks, e.g.:
155
+ ```
156
+ const [create, { isLoading, error }] = useCreate(
157
+ 'rpc/my-function',
158
+ {
159
+ data: { ... },
160
+ meta: { headers: { Prefer: 'params=single-object' } },
161
+ }
162
+ );
163
+ ```
164
+
165
+ ### Vertical filtering
166
+ Postgrest supports a feature of [Vertical Filtering (Columns)](https://postgrest.org/en/stable/api.html#vertical-filtering-columns). Within the react-admin hooks this feature can be used as in the following example:
167
+ ```
168
+ const { data, total, isLoading, error } = useGetList(
169
+ 'posts',
170
+ {
171
+ pagination: { page: 1, perPage: 10 },
172
+ sort: { field: 'published_at', order: 'DESC' }
173
+ meta: { columns: ['id', 'title'] }
174
+ }
175
+ );
176
+ ```
177
+
178
+ Further, one should be able to leverage this feature to rename columns:
179
+ ```
180
+ columns: ['id', 'somealias:title']
181
+ ```
182
+ , to cast columns:
183
+ ```
184
+ columns: ['id::text', 'title']
185
+ ```
186
+ and even get bits from a json or jsonb column"
187
+ ```
188
+ columns: ['id', 'json_data->>blood_type', 'json_data->phones']
189
+ ```
190
+
191
+ **Note**: not working for `create` and `updateMany`.
192
+
160
193
  ## Developers notes
161
194
 
162
195
  The current development of this library was done with node v19.10 and npm 8.19.3. In this version the unit tests and the development environment should work.
163
196
 
164
-
165
197
  ## License
166
198
 
167
199
  This data provider is licensed under the MIT License and sponsored by [raphiniert.com](https://raphiniert.com).