### Install PostgREST JS with npm Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Install the PostgREST JS library using npm. This command adds the package as a project dependency. ```sh $ npm install --save @supabase/postgrest-js ``` -------------------------------- ### Paginate with Range Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Fetch a specific range of rows from the dataset using start and end indices. ```javascript let { body: countries } = await client .from('countries') .select('name') .range(0, 10) ``` -------------------------------- ### Initialize PostgREST Client (Node.js) Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Initialize the PostgREST client using Node.js require syntax. Supply the PostgREST server URL when creating the client instance. ```js const supabase = require('@supabase/postgrest-js') let client = new supabase.PostgrestClient('https://your-postgrest.com') ``` -------------------------------- ### Initialize PostgREST Client (ES6) Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Initialize the PostgREST client using ES6 import syntax. Provide the PostgREST server URL during instantiation. ```js import { PostgrestClient } from ' @supabase/postgrest-js' let client = new PostgrestClient('https://your-postgrest.com') ``` -------------------------------- ### PostgrestClient Constructor Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started The PostgrestClient is initialized with the PostgREST server URL. Optional configuration options can be provided to customize headers, query parameters, and schema selection. ```APIDOC ## PostgrestClient(postgrestURL, OPTIONS) ### Parameters - **postgrestURL** (string) - The URL from where your PostgREST queries originate. - **OPTIONS** (object?) - Optional configuration object. - **headers** (object?) - A key-value object representing custom headers. - **query_params** (object?) - A key-value object for custom query parameters. - **schema** (string?) - Specifies the selected schema for PostgREST versions v7.0.0 and above, provided the schema is included in `db-schema`. ``` -------------------------------- ### PostgrestClient Options Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Configure the PostgREST client with optional headers, query parameters, or a specific schema for PostgREST versions v7.0.0 and above. ```js /** * @param {object?} headers * List of headers as keys and their corresponding values * * @param {object?} query_params * List of query parameters as keys and their corresponding values * * @param {string} schema * If you are using postgREST version v7.0.0 and above, * you can use this to indicate your selected schema. * This is provided that your schema is included in db-schema */ ``` -------------------------------- ### Calling Stored Procedures (RPC) Source: https://github.com/supabase/postgrest-js/wiki/06.-Stored-Procedures Demonstrates how to call a stored procedure named 'echo_city' with an array of parameters. ```APIDOC ## Calling Stored Procedures (RPC) ### Description Allows you to execute stored procedures defined in your database as if they were remote procedure calls. This is useful for encapsulating database logic. ### Method `client.rpc(functionName, functionParameters)` ### Parameters #### functionName - **functionName** (string) - Required - The name of the stored function in the database. #### functionParameters - **functionParameters** (object | array) - Optional - The parameters to be passed to the stored function. The structure depends on the function's definition. ### Request Example ```js let cities = await client .rpc('echo_city', [ { name: 'The Shire' }, { name: 'Mordor' } ]) ``` ### General Filters View all possible filters [here](https://github.com/supabase/postgrest-js/wiki/07.-General-Filters). These can be applied after invoking `.rpc()`. ``` -------------------------------- ### Basic Select Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Fetches data from a table. You can select all columns ('*') or specify a comma-separated list of column names. ```APIDOC ## GET /from ### Description Fetches data from a specified table. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Comma-separated list of columns to select. Defaults to '*'. ### Request Example ```javascript let { body: countries } = await client.from('countries').select('*') let { body: countries } = await client.from('countries').select('name') ``` ### Response #### Success Response (200) - **body** (object) - The fetched data. ``` -------------------------------- ### Configure Insert Options (Upsert) Source: https://github.com/supabase/postgrest-js/wiki/03.-POST The `insert` method accepts an options object. Set `upsert` to `true` to enable upsert functionality. For upserts, primary key columns must be included in the data. ```javascript const options = { upsert: false // Set to true to allow upserting. } ``` -------------------------------- ### Select All and Specific Columns Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Fetch all columns from a table or specify individual columns to retrieve. ```javascript let { body: countries } = await client .from('countries') .select('*') ``` ```javascript let { body: countries } = await client .from('countries') .select('name') ``` -------------------------------- ### Case-Sensitive String Search Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `like` method for case-sensitive string pattern matching. Supports SQL LIKE wildcards ('%', '_'). ```javascript let { body: countries } = await client .from('countries') .like('name', '%Zeal%') .select('*') ``` -------------------------------- ### DELETE with Filters Source: https://github.com/supabase/postgrest-js/wiki/05.-DELETE Demonstrates how to delete rows from a table. It's mandatory to include at least one filter (e.g., .eq(), .gt(), etc.) when performing a delete operation to prevent accidental deletion of all records. ```APIDOC ## DELETE Operation ### Description Deletes rows from a specified table based on provided filters. ### Method DELETE ### Endpoint `/your-table-name` ### Parameters #### Query Parameters Filters such as `.eq()`, `.gt()`, `.lt()`, etc., are required. These are applied to the query string. ### Request Example ```javascript let { status } = await client .from('messages') .eq('message', 'Goodbye World 👋') .delete() ``` ### Response #### Success Response (200 OK) Returns the status of the delete operation. #### Response Example ```json { "status": 200 } ``` ``` -------------------------------- ### Call Stored Procedure with Parameters - JavaScript Source: https://github.com/supabase/postgrest-js/wiki/06.-Stored-Procedures Invoke a stored procedure named 'echo_city' with an array of parameters. Ensure the stored procedure exists in your database. ```javascript let cities = await client .rpc('echo_city', [ { name: 'The Shire' }, { name: 'Mordor' } ]) ``` -------------------------------- ### Insert Data into a Table Source: https://github.com/supabase/postgrest-js/wiki/03.-POST Use the `insert` method to add new rows to a specified table. Provide data as an object or an array of objects. The `from` method specifies the target table. ```javascript let { status } = await client .from('messages') .insert([{ message: 'Hello World 👋'}]) ``` -------------------------------- ### Case-Insensitive String Search Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `ilike` method for case-insensitive string pattern matching. Supports SQL LIKE wildcards ('%', '_'). ```javascript let { body: countries } = await client .from('countries') .ilike('name', '%Zeal%') .select('*') ``` -------------------------------- ### Order Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Sorts the returned data based on one or more columns. Can be applied to main or foreign tables. ```APIDOC ## GET /from/order ### Description Orders the data based on a specified column. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Columns to select. - **order** (string) - Required - The column name to order by. For foreign tables, use `tableName.columnName`. - **sortAscending** (boolean) - Optional - Specifies whether the order is ascending (true) or descending (false). Defaults to false. - **nullsFirst** (boolean) - Optional - Specifies whether null values appear first. Defaults to false. ### Request Example ```javascript // Ordering let { body: countries } = await client.from('countries').select('name').order('name') // Ordering for foreign tables let { body: countries } = await client.from('countries').select(` name, cities ( name ) `).order('cities.name') ``` ### Response #### Success Response (200) - **body** (object) - The ordered data. ``` -------------------------------- ### Single Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Ensures that the response contains exactly one object. If zero or more than one object is found, it returns an error. ```APIDOC ## GET /from/single ### Description Retrieves a single object. Returns an error if zero or more than one object matches the query. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Columns to select. ### Request Example ```javascript let { body: countries } = await client.from('countries').select('name').single() ``` ### Response #### Success Response (200) - **body** (object) - The single matching object. #### Error Response (406) - Returned if zero or more than one object is found. ``` -------------------------------- ### Filter for Exact Value (Null, True, False) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `is` method for exact equality checks with `null`, `true`, or `false`. This is useful for boolean columns or nullable fields. ```javascript let { body: countries } = await client .from('countries') .is('name', null) .select('*') ``` -------------------------------- ### Basic Delete Operation Source: https://github.com/supabase/postgrest-js/wiki/05.-DELETE Use the `.delete()` method on a table to remove rows. It is mandatory to include at least one filter (e.g., `.eq()`) to specify which rows to delete. Failure to do so will result in an error. ```javascript let { status } = await client .from('messages') .eq('message', 'Goodbye World 👋') .delete() ``` -------------------------------- ### Update Records Source: https://github.com/supabase/postgrest-js/wiki/04.-PATCH This snippet demonstrates how to update records in a 'messages' table. It uses the `.from()` method to specify the table and the `.eq()` filter to select the record to update, followed by the `.update()` method to set the new values. A filter is required for the update operation. ```APIDOC ## UPDATE messages ### Description Updates existing records in the 'messages' table. ### Method PATCH ### Endpoint `/messages` ### Parameters #### Query Parameters - **message** (string) - Required - Filter to select the record where the 'message' column equals 'Hello World 👋'. #### Request Body - **message** (string) - Required - The new value for the 'message' column, set to 'Goodbye World 👋'. ### Request Example ```javascript let { status } = await client .from('messages') .eq('message', 'Hello World 👋') .update({ message: 'Goodbye World 👋' }) ``` ### Response #### Success Response (200) - **status** (integer) - The HTTP status code of the response. ``` -------------------------------- ### Fetch Single Object Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Ensure the response contains exactly one object. If zero or more than one object is found, an error will be returned. ```javascript let { body: countries } = await client .from('countries') .select('name') .single() ``` -------------------------------- ### Filter by Exact Equality Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `eq` method for exact equality checks. This is a common filter applicable to strings, integers, and booleans. ```javascript let { body: countries } = await client .from('countries') .eq('name', 'New Zealand') .select('*') ``` -------------------------------- ### Match Multiple Criteria Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `match` method to find rows where all specified column-value pairs are exactly matched. It's equivalent to chaining multiple `filter` calls with the 'eq' operator. ```javascript let { body: countries } = await client .from('countries') .match({ 'continent': 'Asia' }) .select('*') ``` -------------------------------- ### Order Data Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Sort the retrieved data based on a specified column. Supports ordering on columns from foreign tables. ```javascript let { body: countries } = await client .from('countries') .select('name') .order('name') ``` ```javascript let { body: countries } = await client .from('countries') .select( name, cities ( name ) ) .order('cities.name') ``` -------------------------------- ### like(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Performs a case-sensitive string search using the LIKE operator. ```APIDOC ## like(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string) - Required - Value to match. Supports SQL LIKE wildcards (e.g., '%'). ### Example ```js let { body: countries } = await client .from('countries') .like('name', '%Zeal%') .select('*') ``` ``` -------------------------------- ### Offset Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Skips a specified number of rows before returning results. Can be applied to main or foreign tables. ```APIDOC ## GET /from/offset ### Description Sets the starting point for the returned rows by skipping a specified number of rows. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Columns to select. - **offset** (number) - Required - The number of rows to skip. - **foreignTableName** (string) - Optional - The name of the foreign table to apply the offset on. Used if foreign tables are present. ### Request Example ```javascript // Setting offsets let { body: countries } = await client.from('countries').select('*').offset(1) // Setting offsets for foreign tables let { body: countries } = await client.from('countries').select(` name, cities ( name ) `).offset(1, 'cities') ``` ### Response #### Success Response (200) - **body** (object) - The data after applying the offset. ``` -------------------------------- ### Apply a General Filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `filter` method to apply a condition to a query. The criteria type depends on the operator used. ```javascript let { body: countries } = await client .from('countries') .filter('continent', 'eq', 'Asia') .select('*') ``` -------------------------------- ### Query Foreign Tables Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Retrieve data from a table along with related data from a foreign table, specifying columns from both. ```javascript let { body: countries } = await client .from('countries') .select( name, cities ( name ) ) ``` -------------------------------- ### Plain Full-Text Search (plfts) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `plfts` method for full-text search on a `tsvector` column. It uses `plainto_tsquery` for matching. ```javascript let { body: countries } = await client .from('characters') .plfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` -------------------------------- ### Querying Foreign Tables Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Allows fetching data from related tables by specifying nested selections for foreign key columns. ```APIDOC ## GET /from/select with foreign tables ### Description Fetches data from the main table and its related foreign tables. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Comma-separated list of columns, including nested selections for foreign tables (e.g., 'name, cities {name}'). ### Request Example ```javascript let { body: countries } = await client.from('countries').select(` name, cities ( name ) `) ``` ### Response #### Success Response (200) - **body** (object) - The fetched data, including nested data from foreign tables. ``` -------------------------------- ### Phrase Full-Text Search (phfts) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `phfts` method for full-text search on a `tsvector` column. It uses `phraseto_tsquery` for matching. ```javascript let { body: countries } = await client .from('characters') .phfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` -------------------------------- ### Update a record in a table Source: https://github.com/supabase/postgrest-js/wiki/04.-PATCH Use this snippet to update a specific record in a database table. Ensure you use at least one filter (e.g., `eq()`) to target the correct record. ```javascript let { status } = await client .from('messages') .eq('message', 'Hello World 👋') .update({ message: 'Goodbye World 👋' }) ``` -------------------------------- ### Full-Text Search (fts) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `fts` method for full-text search on a `tsvector` column. It uses `to_tsquery` for matching. ```javascript let { body: countries } = await client .from('characters') .fts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` -------------------------------- ### Range Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Retrieves a specific range of rows from the dataset. This is useful for pagination. ```APIDOC ## GET /from/range ### Description Paginates the request by specifying a range of rows to return. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Columns to select. - **range** (string) - Required - A string representing the range, e.g., '0-10'. ### Request Example ```javascript // Pagination let { body: countries } = await client.from('countries').select('name').range(0, 10) ``` ### Response #### Success Response (200) - **body** (object) - The data within the specified range. ``` -------------------------------- ### match(filterObject) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows that exactly match all conditions specified in the filter object. This is equivalent to multiple 'eq' filters chained together. ```APIDOC ## match(filterObject) ### Parameters - **filterObject** (object) - Required - An object containing multiple columnNames as keys and their respective criteria to match as values. ### Example ```js let { body: countries } = await client .from('countries') .match({ 'continent': 'Asia' }) .select('*') ``` ``` -------------------------------- ### Insert Data Source: https://github.com/supabase/postgrest-js/wiki/03.-POST Inserts a single object or an array of objects into the selected table. The `upsert` option can be set to `true` to allow upserting. ```APIDOC ## POST /rest/v1/{table} ### Description Inserts data into a specified table. Supports inserting single objects or arrays of objects. Can be configured to perform an upsert operation. ### Method POST ### Endpoint `/rest/v1/{tableName}` ### Parameters #### Path Parameters - **tableName** (string) - Required - The name of the database table to insert data into. #### Request Body - **data** (object | array) - Required - A single object or an array of objects representing the rows to be inserted. - **options** (object) - Optional - Configuration options for the insert operation. - **upsert** (boolean) - Optional - Defaults to `false`. If `true`, allows upserting. For upserting, primary key columns must be included in the `data`. ### Request Example ```json { "message": "Hello World 👋" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation. ``` -------------------------------- ### Filter by Less Than or Equal To Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `lte` method to select rows where the column's value is less than or equal to the specified criteria. Applicable to strings, integers, and booleans. ```javascript let { body: countries } = await client .from('countries') .lte('id', 20) .select('*') ``` -------------------------------- ### Apply a Negated Filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `not` method to exclude rows that meet the specified criteria. This reverses the logic of the `filter` method. ```javascript let { body: countries } = await client .from('countries') .not('continent', 'eq', 'Asia') .select('*') ``` -------------------------------- ### Limit Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Restricts the number of rows returned in the query. Can be applied to main or foreign tables. ```APIDOC ## GET /from/limit ### Description Limits the number of rows returned. ### Method GET ### Endpoint `/from/{tableName}` ### Parameters #### Query Parameters - **select** (string) - Required - Columns to select. - **limit** (number) - Required - The maximum number of items to return. - **foreignTableName** (string) - Optional - The name of the foreign table to apply the limit on. Used if foreign tables are present. ### Request Example ```javascript // Limiting let { body: countries } = await client.from('countries').select('*').limit(1) // Limiting for foreign tables let { body: countries } = await client.from('countries').select(` name, cities ( name ) `).limit(1, 'cities') ``` ### Response #### Success Response (200) - **body** (object) - The limited data. ``` -------------------------------- ### Offset Results Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Skip a specified number of rows before returning results. This can also be applied to foreign tables. ```javascript let { body: countries } = await client .from('countries') .select('*') .offset(1) ``` ```javascript let { body: countries } = await client .from('countries') .select( name, cities ( name ) ) .offset(1, 'cities') ``` -------------------------------- ### Filter by Not Equal Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `neq` method to find rows where the column value is not equal to the specified criteria. Applicable to strings, integers, and booleans. ```javascript let { body: countries } = await client .from('countries') .neq('name', 'New Zealand') .select('*') ``` -------------------------------- ### Find rows matching websearch_to_tsquery Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use `wfts` to find rows where a tsvector column matches a websearch query. Specify the column name, query text, and optionally a configuration. ```javascript let { body: countries } = await client .from('characters') .wfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` -------------------------------- ### filter(columnName, operator, criteria) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Applies a filter to the query based on a specified column, operator, and criteria. Filters can be chained together for complex queries. ```APIDOC ## filter(columnName, operator, criteria) ### Parameters - **columnName** (string) - Required - Name of the database column. - **operator** (string) - Required - Name of filter operator to be utilised. These can be found below, under Common Filters. - **criteria** ({ object | array | string | integer | boolean | null }) - Required - Value to compare to. Exact data type of criteria would depend on the operator used. ### Example ```js let { body: countries } = await client .from('countries') .filter('continent', 'eq', 'Asia') .select('*') ``` ``` -------------------------------- ### Limit Results Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Restrict the number of rows returned by the query. Can be applied to foreign tables as well. ```javascript let { body: countries } = await client .from('countries') .select('*') .limit(1) ``` ```javascript let { body: countries } = await client .from('countries') .select( name, cities ( name ) ) .limit(1, 'cities') ``` -------------------------------- ### ilike(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Performs a case-insensitive string search using the ILIKE operator. ```APIDOC ## ilike(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string) - Required - Value to match. Supports SQL LIKE wildcards (e.g., '%'). ### Example ```js let { body: countries } = await client .from('countries') .ilike('name', '%Zeal%') .select('*') ``` ``` -------------------------------- ### Filter by Less Than Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `lt` method to select rows where the column's value is strictly less than the specified criteria. Applicable to strings, integers, and booleans. ```javascript let { body: countries } = await client .from('countries') .lt('id', 20) .select('*') ``` -------------------------------- ### Filter by Inclusion in a List Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `in` method to select rows where the column's value is present in the provided array. The array can contain strings, integers, or booleans. ```javascript let { body: countries } = await client .from('countries') .in('name', ['China', 'France']) .select('*') ``` -------------------------------- ### is(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows for exact equality, specifically for null, true, or false values. ```APIDOC ## is(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ null | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .is('name', null) .select('*') ``` ``` -------------------------------- ### nxl() - Does Not Extend to the Left Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a range column does not extend to the left of the specified range. The input array must contain exactly two elements representing the range. ```APIDOC ## nxl(columnName, filterValue) ### Description Checks if a range column does not extend to the left of the specified range. ### Method client.from('table_name').nxl(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The range to compare against. Must contain exactly two elements [start, end]. ``` -------------------------------- ### cs() - Contains Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a column contains the specified values. This can be used for arrays or JSON objects. ```APIDOC ## cs(columnName, filterValue) ### Description Checks if a column contains the specified values. ### Method client.from('table_name').cs(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array | object` - The values to check for containment within the column. ``` -------------------------------- ### nxr() - Does Not Extend to the Right Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a range column does not extend to the right of the specified range. The input array must contain exactly two elements representing the range. ```APIDOC ## nxr(columnName, filterValue) ### Description Checks if a range column does not extend to the right of the specified range. ### Method client.from('table_name').nxr(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The range to compare against. Must contain exactly two elements [start, end]. ``` -------------------------------- ### Filter by Greater Than or Equal To Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `gte` method to select rows where the column's value is greater than or equal to the specified criteria. Applicable to strings, integers, and booleans. ```javascript let { body: countries } = await client .from('countries') .gte('id', 20) .select('*') ``` -------------------------------- ### cd() - Contained In Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a column is contained within the specified values. This can be used for arrays or JSON objects. ```APIDOC ## cd(columnName, filterValue) ### Description Checks if a column is contained within the specified values. ### Method client.from('table_name').cd(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array | object` - The values to check if the column is contained within. ``` -------------------------------- ### ova() - Overlaps (Arrays) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if an array column overlaps with the specified array. Both arrays must share at least one common element. ```APIDOC ## ova(columnName, filterValue) ### Description Checks if an array column overlaps with the specified array. ### Method client.from('table_name').ova(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The array to compare against. Must share at least one element with the column's array. ``` -------------------------------- ### neq(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the specified column is not equal to the provided value. ```APIDOC ## neq(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ string | integer | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .neq('name', 'New Zealand') .select('*') ``` ``` -------------------------------- ### Filter by Greater Than Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `gt` method to select rows where the column's value is strictly greater than the specified criteria. Applicable to strings, integers, and booleans. ```javascript let { body: countries } = await client .from('countries') .gt('id', 20) .select('*') ``` -------------------------------- ### eq(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the specified column is equal to the provided value. ```APIDOC ## eq(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ string | integer | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .eq('name', 'New Zealand') .select('*') ``` ``` -------------------------------- ### not(columnName, operator, criteria) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Reverses the filter condition. Returns rows that do not meet the specified criteria. ```APIDOC ## not(columnName, operator, criteria) ### Parameters - **columnName** (string) - Required - Name of the database column. - **operator** (string) - Required - Name of filter operator to be utilised. These can be found below, under Common Filters. - **criteria** ({ object | array | string | integer | boolean | null }) - Required - Value to compare to. Exact data type of criteria would depend on the operator used. ### Example ```js let { body: countries } = await client .from('countries') .not('continent', 'eq', 'Asia') .select('*') ``` ``` -------------------------------- ### phfts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Performs a full-text search on a tsvector column, matching against a phraseto_tsquery. ```APIDOC ## phfts(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - An object containing search parameters. - **queryText** (string) - Required - The text to search for. - **config** (string?) - Optional - The configuration to apply for the search. ### Example ```js let { body: countries } = await client .from('characters') .phfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### plfts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Performs a full-text search on a tsvector column, matching against a plainto_tsquery. ```APIDOC ## plfts(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - An object containing search parameters. - **queryText** (string) - Required - The text to search for. - **config** (string?) - Optional - The configuration to apply for the search. ### Example ```js let { body: countries } = await client .from('characters') .plfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### fts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Performs a full-text search on a tsvector column, matching against a to_tsquery. ```APIDOC ## fts(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - An object containing search parameters. - **queryText** (string) - Required - The text to search for. - **config** (string?) - Optional - The configuration to apply for the search. ### Example ```js let { body: countries } = await client .from('characters') .fts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### Filter rows where a range does not extend to the left of specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `nxl` filter to select rows where a range column does not extend to the left of a specified two-element array. The array must have a length of 2. ```javascript let { body: countries } = await client .from('countries') .nxl('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### lte(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the specified column's value is less than or equal to the provided value. ```APIDOC ## lte(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ string | integer | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .lte('id', 20) .select('*') ``` ``` -------------------------------- ### lt(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the specified column's value is less than the provided value. ```APIDOC ## lt(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ string | integer | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .lt('id', 20) .select('*') ``` ``` -------------------------------- ### Filter rows where a range does not extend to the right of specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `nxr` filter to select rows where a range column does not extend to the right of a specified two-element array. The array must have a length of 2. ```javascript let { body: countries } = await client .from('countries') .nxr('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### ovr() - Overlaps (Ranges) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a range column overlaps with the specified range. The input array must contain exactly two elements representing the range. ```APIDOC ## ovr(columnName, filterValue) ### Description Checks if a range column overlaps with the specified range. ### Method client.from('table_name').ovr(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The range to compare against. Must contain exactly two elements [start, end]. ``` -------------------------------- ### sl() - Strictly Left Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a range column is strictly to the left of the specified range. The input array must contain exactly two elements representing the range. ```APIDOC ## sl(columnName, filterValue) ### Description Checks if a range column is strictly to the left of the specified range. ### Method client.from('table_name').sl(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The range to compare against. Must contain exactly two elements [start, end]. ``` -------------------------------- ### wfts() - Web Search Full Text Search Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows where the tsvector column matches a web search query. Supports specifying a configuration for the search. ```APIDOC ## wfts(columnName, filterValue) ### Description Finds rows whose tsvector values on the stated columnName matches websearch_to_tsquery(queryText). ### Method client.from('table_name').wfts(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `object` - **queryText** (string) - Required - The text to search for. - **config** (string) - Optional - The full-text search configuration to use. ``` -------------------------------- ### sr() - Strictly Right Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a range column is strictly to the right of the specified range. The input array must contain exactly two elements representing the range. ```APIDOC ## sr(columnName, filterValue) ### Description Checks if a range column is strictly to the right of the specified range. ### Method client.from('table_name').sr(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The range to compare against. Must contain exactly two elements [start, end]. ``` -------------------------------- ### adj() - Adjacent Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Checks if a range column is adjacent to the specified range. The input array must contain exactly two elements representing the range. ```APIDOC ## adj(columnName, filterValue) ### Description Checks if a range column is adjacent to the specified range. ### Method client.from('table_name').adj(columnName, filterValue).select('*') ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### filterValue `array` - The range to compare against. Must contain exactly two elements [start, end]. ``` -------------------------------- ### gte(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the specified column's value is greater than or equal to the provided value. ```APIDOC ## gte(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ string | integer | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .gte('id', 20) .select('*') ``` ``` -------------------------------- ### Filter rows where an array overlaps with specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `ova` filter to select rows where a column's array value has at least one element in common with the specified array. ```javascript let { body: countries } = await client .from('countries') .ova('main_exports', ['computers', 'minerals']) .select('*') ``` -------------------------------- ### gt(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the specified column's value is greater than the provided value. ```APIDOC ## gt(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** ({ string | integer | boolean }) - Required - Value to match. ### Example ```js let { body: countries } = await client .from('countries') .gt('id', 20) .select('*') ``` ``` -------------------------------- ### Filter rows where a column contains specific values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `cs` filter to select rows where a column's array value contains all specified elements. ```javascript let { body: countries } = await client .from('countries') .cs('main_exports', ['oil']) .select('*') ``` -------------------------------- ### Filter rows where a range overlaps with specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `ovr` filter to select rows where a range column overlaps with a specified two-element array. The array must have a length of 2. ```javascript let { body: countries } = await client .from('countries') .ovr('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### Filter rows where a range is strictly to the right of specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `sr` filter to select rows where a range column is strictly to the right of a specified two-element array. The array must have a length of 2. ```javascript let { body: countries } = await client .from('countries') .sr('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### Filter rows where a range is adjacent to specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `adj` filter to select rows where a range column is adjacent to a specified two-element array. The array must have a length of 2. ```javascript let { body: countries } = await client .from('countries') .adj('population_range_millions', [70, 185]) .select('*') ``` -------------------------------- ### Filter rows where a range is strictly to the left of specified values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `sl` filter to select rows where a range column is strictly to the left of a specified two-element array. The array must have a length of 2. ```javascript let { body: countries } = await client .from('countries') .sl('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### in(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column's value is present in the provided list. ```APIDOC ## in(columnName, filterValue) ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array) - Required - An array of values to check for. ### Example ```js let { body: countries } = await client .from('countries') .in('name', ['China', 'France']) .select('*') ``` ``` -------------------------------- ### Filter rows where a column is contained within specific values Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Use the `cd` filter to select rows where a column's array value is contained within the specified array. ```javascript let { body: countries } = await client .from('countries') .cd('main_exports', ['cars', 'food', 'machine']) .select('*') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.