ra-data-postgrest icon indicating copy to clipboard operation
ra-data-postgrest copied to clipboard

Allow columns filtering for getList and getManyReference

Open christiaanwesterbeek opened this issue 2 years ago • 1 comments

Add support for Postgrest's Vertical Filtering (Columns).

When certain columns are wide (such as those holding binary data), it is more efficient for the server to withhold them in a response. The client can specify which columns are required using the select parameter.

Example usage

const { data, total, isLoading, error } = useGetList(
    'posts',
    { 
        pagination: { page: 1, perPage: 10 },
        sort: { field: 'published_at', order: 'DESC' }
        meta: { columns: ['id', 'title'] }
    }
);

But you should be able to leverage this feature to rename columns:

columns: ['id', 'somealias:title']

and to cast columns:

columns: ['id::text', 'title']

and even get bits from a json or jsonb column"

columns: ['id', 'json_data->>blood_type', 'json_data->phones']

christiaanwesterbeek avatar Sep 01 '22 13:09 christiaanwesterbeek

This PR only enables column filtering for getList and getManyReference. Column filtering for getOne and getMany would be another PR...

christiaanwesterbeek avatar Sep 01 '22 14:09 christiaanwesterbeek

was included in https://github.com/raphiniert-com/ra-data-postgrest/pull/74

scheiblr avatar Apr 09 '23 00:04 scheiblr