{"id":13550480,"url":"https://github.com/ivangabriele/postgrester","last_synced_at":"2025-04-03T00:34:01.922Z","repository":{"id":39643100,"uuid":"209035003","full_name":"ivangabriele/postgrester","owner":"ivangabriele","description":"Isomorphic PostgREST API Client for Javascript and Typescript.","archived":true,"fork":false,"pushed_at":"2023-03-17T17:21:32.000Z","size":1668,"stargazers_count":51,"open_issues_count":7,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-09T08:42:22.716Z","etag":null,"topics":["api","api-client","isomorphic","javascript","postgrest","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ivangabriele.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-09-17T11:25:07.000Z","updated_at":"2024-11-01T01:17:07.000Z","dependencies_parsed_at":"2024-01-19T07:07:25.537Z","dependency_job_id":"66399740-8dfd-418d-80c6-f696057fd1ef","html_url":"https://github.com/ivangabriele/postgrester","commit_stats":{"total_commits":298,"total_committers":8,"mean_commits":37.25,"dds":0.5939597315436241,"last_synced_commit":"0a9525cc41db3d7fd2d40816ce5258a8d0fc9e29"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangabriele%2Fpostgrester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangabriele%2Fpostgrester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangabriele%2Fpostgrester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangabriele%2Fpostgrester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivangabriele","download_url":"https://codeload.github.com/ivangabriele/postgrester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246916733,"owners_count":20854511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","api-client","isomorphic","javascript","postgrest","typescript"],"created_at":"2024-08-01T12:01:33.740Z","updated_at":"2025-04-03T00:34:00.921Z","avatar_url":"https://github.com/ivangabriele.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# postgrester\n\n**⚠️ THIS PACKAGE IS DEPRECATED AND NO LONGER MAINTAINED,\nYOU CAN USE [@supabase/postgrest-js](https://github.com/supabase/postgrest-js) AS A REPLACEMENT.**\n\n---\n\n[![License][img-license]][lnk-license]\n[![NPM Package][img-npm]][lnk-npm]\n[![Build Status][img-github]][lnk-github]\n[![Code Coverage][img-codecov]][lnk-codecov]\n\nIsomorphic [PostgREST][lnk-postgrest] API Client for Javascript and Typescript.\n\nSupported PostgREST versions:\n\n- `v9.0.0`\n- `v8.0.0`\n\n---\n\n- [Gettting Started](#gettting-started)\n- [Example](#example)\n- [API](#api)\n  - [Options](#options)\n  - [Vertical Filtering (columns) Methods](#vertical-filtering-columns-methods)\n    - [select()](#select)\n  - [Hoizontal Filtering (rows) Methods](#hoizontal-filtering-rows-methods)\n    - [is()](#is)\n    - [eq()](#eq)\n    - [neq()](#neq)\n    - [gt()](#gt)\n    - [gte()](#gte)\n    - [lt()](#lt)\n    - [lte()](#lte)\n    - [in()](#in)\n    - [like()](#like)\n    - [ilike()](#ilike)\n    - [not](#not)\n    - [and](#and)\n    - [or](#or)\n  - [Ordering Methods](#ordering-methods)\n    - [orderBy()](#orderby)\n  - [Pagination Methods](#pagination-methods)\n    - [page()](#page)\n  - [Request Methods](#request-methods)\n    - [get()](#get)\n    - [post() / Insert](#post--insert)\n    - [post() / Upsert](#post--upsert)\n    - [patch()](#patch)\n    - [put()](#put)\n    - [delete()](#delete)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Gettting Started\n\n```bash\nnpm i postgrester\n```\n\n## Example\n\n```js\nimport { create } from \"postgrester\";\n\nconst postgrestClient = create({\n  axiosConfig: { baseURL: \"https://api.example.com\" }\n});\n\n(async () =\u003e {\n  const { data, pagesLength } = await postgrestClient\n    .select(\"*\")\n    .select(\"author(first_name,last_name)\")\n    .is(\"is_published\", true)\n    .not.is(\"isbn\", null)\n    .eq(\"publication_year\", 1970)\n    .in(\"language_code\", [\"en-UK\", \"en-US\"])\n    .ilike(\"title\", \"island\")\n    .like(\"author.last_name\", \"Hemingway\")\n    .orderBy(\"publication_year\", true) // `true` = DESC\n    .orderBy(\"title\")\n    .page(3, 25) // 4th page with 25 items per page\n    .get(\"/books\", true); // `true` = require the total `pagesLength` value to be calculated\n})();\n```\n\n## API\n\n### Options\n\nWhen creating the instance via `create([options])`:\n\n| Property        | Type                 | Default | Description                                |\n| --------------- | -------------------- | ------- | ------------------------------------------ |\n| `axiosConfig`   | `AxiosRequestConfig` | `{}`    | Axios config called with `axios.create()`. |\n| `axiosInstance` | `AxiosInstance`      | `null`  | Axios custom instance.                     |\n| _`baseUri`_     | _`string`_           | _`\"\"`_  | _API URL. \u003ckbd\u003eDeprecated\u003c/kbd\u003e_           |\n\n\u003e :warning: If you provide an axios instance via the `axiosInstance` property, it's useless to\n\u003e set `axiosConfig` since it would be overridden by your instance.\n\n\u003e :warning: `baseUri` takes precedence over `axiosConfig.baseURL`. To avoid any confusion,\n\u003e `baseUri` will be **deprecated** in the next minor version release and should be removed in the\n\u003e next major one.\n\n### Vertical Filtering (columns) Methods\n\n#### select()\n\n| Name       | Type     | Default      | Examples                                  |\n| ---------- | -------- | ------------ | ----------------------------------------- |\n| `selector` | `string` | **required** | `\"*\"`, `\"author\"`, `\"category(id,label)\"` |\n\nYou can also rename them by inserting a colon: `original_column_name:new_column_name`.\n\n### Hoizontal Filtering (rows) Methods\n\n#### is()\n\n| Name     | Type              | Default      | Examples                       |\n| -------- | ----------------- | ------------ | ------------------------------ |\n| `column` | `string`          | **required** | `\"author\"`, `\"category.label\"` |\n| `value`  | `boolean \\| null` | **required** |                                |\n\n#### eq()\n\n| Name         | Type                                  | Default      | Examples                       |\n| ------------ | ------------------------------------- | ------------ | ------------------------------ |\n| `column`     | `string`                              | **required** | `\"author\"`, `\"category.label\"` |\n| `value`      | `boolean \\| number \\| null \\| string` | **required** | `\"Leo Tolstoy\"`                |\n| `withQuotes` | `boolean`                             | `false`      |                                |\n\n\u003e **Note:** `boolean` and `null` values will be converted into an `is()`.\n\n#### neq()\n\n| Name         | Type                                  | Default      | Examples                       |\n| ------------ | ------------------------------------- | ------------ | ------------------------------ |\n| `column`     | `string`                              | **required** | `\"author\"`, `\"category.label\"` |\n| `value`      | `boolean \\| number \\| null \\| string` | **required** | `\"Leo Tolstoy\"`                |\n| `withQuotes` | `boolean`                             | `false`      |                                |\n\n\u003e **Note:** `boolean` and `null` values will be converted into a **negated** `is()`.\n\n#### gt()\n\n| Name          | Type               | Default      | Examples                              |\n| ------------- | ------------------ | ------------ | ------------------------------------- |\n| `column`      | `string`           | **required** | `\"quantity\"`, `\"category.updated_at\"` |\n| `value`       | `number \\| string` | **required** |                                       |\n| `isInclusive` | `boolean`          | `false`      |                                       |\n\n#### gte()\n\n| Name     | Type               | Default      | Examples                              |\n| -------- | ------------------ | ------------ | ------------------------------------- |\n| `column` | `string`           | **required** | `\"quantity\"`, `\"category.updated_at\"` |\n| `value`  | `number \\| string` | **required** |                                       |\n\n\u003e **Note:** This method is an alias for `gt()` with `\u003cisInclusive\u003e` set to `true`.\n\n#### lt()\n\n| Name          | Type               | Default      | Examples                              |\n| ------------- | ------------------ | ------------ | ------------------------------------- |\n| `column`      | `string`           | **required** | `\"quantity\"`, `\"category.updated_at\"` |\n| `value`       | `number \\| string` | **required** |                                       |\n| `isInclusive` | `boolean`          | `false`      |                                       |\n\n#### lte()\n\n| Name     | Type               | Default      | Examples                              |\n| -------- | ------------------ | ------------ | ------------------------------------- |\n| `column` | `string`           | **required** | `\"quantity\"`, `\"category.updated_at\"` |\n| `value`  | `number \\| string` | **required** |                                       |\n\n\u003e **Note:** This method is an alias for `lt()` with `\u003cisInclusive\u003e` set to `true`.\n\n#### in()\n\n| Name         | Type                      | Default      | Examples                               |\n| ------------ | ------------------------- | ------------ | -------------------------------------- |\n| `column`     | `string`                  | **required** | `\"author\"`, `\"category.label\"`         |\n| `value`      | `Array\u003cnumber \\| string\u003e` | **required** | `[\"Leo Tolstoy\", \"Fyodor Dostoevsky\"]` |\n| `withQuotes` | `boolean`                 | `false`      |                                        |\n\n#### like()\n\n| Name     | Type     | Default      | Examples                       |\n| -------- | -------- | ------------ | ------------------------------ |\n| `column` | `string` | **required** | `\"author\"`, `\"category.label\"` |\n| `value`  | `string` | **required** | `\"Tolstoy\"`                    |\n\n#### ilike()\n\n| Name     | Type     | Default      | Examples                       |\n| -------- | -------- | ------------ | ------------------------------ |\n| `column` | `string` | **required** | `\"author\"`, `\"category.label\"` |\n| `value`  | `string` | **required** | `\"tolstoy\"`                    |\n\n#### not\n\nThis getter **ONLY** negates the **FIRST** following filtering method.\n\nFor example, `postgrestClient.not.is(\"category_id\", null).ilike(\"author\", \"dostoevsky\")` will\n**negate** the `is()` filter but not the `ilike()` one.\n\n#### and\n\nThis getter condition **ALL** the following filtering methods to be conjuncted as \"ands\".\n\nFor example, `postgrestClient.and.is(\"category_id\", null).ilike(\"author\", \"dostoevsky\")` will\n**intersect** both `is()` and `ilike()` filters.\n\n#### or\n\nThis getter condition **ALL** the following filtering methods to be conjuncted as \"ors\".\n\nFor example, `postgrestClient.and.is(\"category_id\", null).ilike(\"author\", \"dostoevsky\")` will\n**unite** both `is()` and `ilike()` filters.\n\n### Ordering Methods\n\n#### orderBy()\n\n| Name     | Type      | Default      | Examples                       |\n| -------- | --------- | ------------ | ------------------------------ |\n| `column` | `string`  | **required** | `\"author\"`, `\"category.label\"` |\n| `isDesc` | `boolean` | `false`      |                                |\n\n### Pagination Methods\n\n#### page()\n\n| Name        | Type     | Default      | Examples   |\n| ----------- | -------- | ------------ | ---------- |\n| `pageIndex` | `number` | **required** | `0`, `123` |\n| `limit`     | `number` | `10`         |            |\n\n### Request Methods\n\nAll request methods are asynchronous promises.\n\n#### get()\n\n| Name              | Type      | Default      | Examples   |\n| ----------------- | --------- | ------------ | ---------- |\n| `path`            | `string`  | **required** | `\"/books\"` |\n| `withPagesLength` | `boolean` | `false`      |            |\n\nReturn value:\n\n```ts\nPromise\u003c{\n  data: any;\n  pagesLength: number;\n  totalLength: number;\n}\u003e\n```\n\n\u003e **:warning: Important**\u003cbr\u003e\n\u003e Both `pagesLength` and `totalLength` will equal `-1` if `\u003cwithPagesLength\u003e` parameter is `false`\n\u003e or if the length couldn't be resolved.\n\n#### post() / Insert\n\n| Name      | Type                                              | Default      | Examples   |\n| --------- | ------------------------------------------------- | ------------ | ---------- |\n| `path`    | `string`                                          | **required** | `\"/books\"` |\n| `data`    | `object`                                          | **required** |            |\n| `options` | `{ return?: 'headers-only' \\| 'representation' }` |              |            |\n\nReturn value:\n\n```ts\nPromise\u003cvoid\u003e\n```\n\nor (with `{ return: \"representation\" }`):\n\n```ts\nPromise\u003c{\n  data: T\n}\u003e\n```\n\n#### post() / Upsert\n\n\u003e **:warning: Important**  \n\u003e If `data` is an array, it will be considered as an [upsert](https://postgrest.org/en/v9.0/api.html#upsert).  \n\u003e In this case, if you don't specify otherwise in `options`, `merge-duplicates` resolution will be used by default.\n\n| Name      | Type                                                                                                                           | Default                              | Examples   |\n| --------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ | ---------- |\n| `path`    | `string`                                                                                                                       | **required**                         | `\"/books\"` |\n| `data`    | `object[]`                                                                                                                     | **required**                         |            |\n| `options` | `{ onConflict?: string, resolution?: \"ignore-duplicates\" \\| \"merge-duplicates\", return?: 'headers-only' \\| 'representation' }` | `{ resolution: \"merge-duplicates\" }` |            |\n\nReturn value:\n\n```ts\nPromise\u003cvoid\u003e\n```\n\nor (with `{ return: \"representation\" }`):\n\n```ts\nPromise\u003c{\n  data: T[]\n}\u003e\n```\n\n#### patch()\n\n| Name   | Type     | Default      | Examples   |\n| ------ | -------- | ------------ | ---------- |\n| `path` | `string` | **required** | `\"/books\"` |\n| `data` | `object` | **required** |            |\n\nReturn value:\n\n```ts\nPromise\u003cvoid\u003e\n```\n\n#### put()\n\n| Name   | Type     | Default      | Examples   |\n| ------ | -------- | ------------ | ---------- |\n| `path` | `string` | **required** | `\"/books\"` |\n| `data` | `object` | **required** |            |\n\nReturn value:\n\n```ts\nPromise\u003cvoid\u003e\n```\n\n#### delete()\n\n| Name      | Type                                              | Default      | Examples   |\n| --------- | ------------------------------------------------- | ------------ | ---------- |\n| path      | `string`                                          | **required** | `\"/books\"` |\n| `options` | `{ return?: 'headers-only' \\| 'representation' }` |              |            |\n\nReturn value:\n\n```ts\nPromise\u003cvoid\u003e\n```\n\nor (with `{ return: \"representation\" }`):\n\n```ts\nPromise\u003c{\n  data: T[]\n}\u003e\n```\n\n## Contribute\n\nPlease check our [contributing documentation][lnk-contributing].\n\n## License\n\nThis package and its sources are distributed under [Apache 2.0][lnk-license].\n\n---\n\n[img-codecov]: https://img.shields.io/codecov/c/github/ivangabriele/postgrester/main?style=flat-square\n[img-github]: https://img.shields.io/github/workflow/status/ivangabriele/postgrester/Check/main?style=flat-square\n[img-license]: https://img.shields.io/github/license/ivangabriele/postgrester?style=flat-square\n[img-npm]: https://img.shields.io/npm/v/postgrester?style=flat-square\n[lnk-contributing]: https://github.com/ivangabriele/postgrester/blob/main/CONTRIBUTING.md\n[lnk-codecov]: https://codecov.io/gh/ivangabriele/postgrester/branch/main\n[lnk-github]: https://github.com/ivangabriele/postgrester/actions?query=branch%3Amain++\n[lnk-license]: https://github.com/ivangabriele/postgrester/blob/main/LICENSE\n[lnk-npm]: https://www.npmjs.com/package/postgrester\n[lnk-postgrest]: http://postgrest.org\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangabriele%2Fpostgrester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivangabriele%2Fpostgrester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangabriele%2Fpostgrester/lists"}