### Install Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Installation instructions for the @supabase/postgrest-js package using npm. ```APIDOC ## Install ```sh $ npm install --save @supabase/postgrest-js ``` ``` -------------------------------- ### Install @supabase/postgrest-js with npm Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Installs the @supabase/postgrest-js package via npm. ```sh $ npm install --save @supabase/postgrest-js ``` -------------------------------- ### Paginate with range Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Paginate results by specifying a range of indices. The range method takes a starting index and an optional ending index; if the ending index is omitted, all remaining rows are returned. ```js // Pagination let { body: countries } = await client .from('countries') .select('name') .range(0, 10) ``` -------------------------------- ### Insert a row into a table Source: https://github.com/supabase/postgrest-js/wiki/03.-POST Inserts a single row into the 'messages' table. The response is destructured to get the 'status' property. ```javascript let { status } = await client .from('messages') .insert([{ message: 'Hello World 👋']) ``` -------------------------------- ### Initialize Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Shows how to initialize the PostgrestClient in both ES6 and Node.js environments. ```APIDOC ## Initialize ### ES6 ```js import { PostgrestClient } from ' @supabase/postgrest-js' let client = new PostgrestClient('https://your-postgrest.com') ``` ### Node.js ```js const supabase = require('@supabase/postgrest-js') let client = new supabase.PostgrestClient('https://your-postgrest.com') ``` ``` -------------------------------- ### PostgrestClient(postgrestURL, OPTIONS) Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Documentation for the PostgrestClient constructor, including its parameters and options. ```APIDOC ## PostgrestClient(postgrestURL, OPTIONS) ### Description Creates a new PostgrestClient instance to interact with a PostgREST server. ### Parameters - **postgrestURL** (string) - Required - The URL from where your postgREST queries. - **OPTIONS** (object?) - Optional - Configuration options. - **headers** (object?) - List of headers as keys and their corresponding values. - **query_params** (object?) - List of query parameters as keys and their corresponding values. - **schema** (string) - 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. ``` -------------------------------- ### Initialize PostgrestClient with ES6 import Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Initializes a PostgrestClient using ES6 import syntax. ```js import { PostgrestClient } from ' @supabase/postgrest-js' let client = new PostgrestClient('https://your-postgrest.com') ``` -------------------------------- ### PostgREST-js Basics Source: https://github.com/supabase/postgrest-js/wiki/03.-POST Documentation for the from and insert methods of the PostgREST-js client. ```APIDOC ## from(tableName) ### Description Sets the table to be queried or modified. This method is used to specify the database table that subsequent operations (like insert) will act on. ### Method from ### Parameters - **tableName** (string) - Required - Name of the database table that will be read from. ### Example ```js client.from('messages') ``` ``` ```APIDOC ## insert(data, options = {upsert: false}) ### Description Inserts a single row or multiple rows into the selected table. Optionally, it can perform an upsert operation if the `upsert` option is set to true. ### Method insert ### Parameters - **data** (object | array) - Required - A single object or an array of row objects containing information to be saved into the selected table. - **options** (object) - Optional - Configuration options for the insert operation. - **upsert** (boolean) - Optional - Set to true to allow upserting. Default is false. For upsert, primary key columns must be included in the data parameter, and primary keys must be natural, not surrogate. ### Example ```js let { status } = await client .from('messages') .insert([{ message: 'Hello World 👋' }]) ``` ``` -------------------------------- ### Initialize PostgrestClient with Node.js require Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started Initializes a PostgrestClient using CommonJS require syntax for Node.js. ```js const supabase = require('@supabase/postgrest-js') let client = new supabase.PostgrestClient('https://your-postgrest.com') ``` -------------------------------- ### from(tableName) Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Initializes a query on a specific table. ```APIDOC ## from(tableName) ### Description Sets the table to query from. This is the starting point for all queries. ### Parameters - **tableName** (string) - Required - Name of the database table that will be read from. ### Example ```js let { body: countries } = await client .from('countries') .select('*') ``` ``` -------------------------------- ### Basic Stored Procedure Call using .rpc() Source: https://github.com/supabase/postgrest-js/wiki/06.-Stored-Procedures Calls the 'echo_city' stored procedure with an array of objects as parameters, passing two city names. Demonstrates the basic syntax for invoking a database function. ```JavaScript let cities = await client .rpc('echo_city', [ { name: 'The Shire' }, { name: 'Mordor' } ]) ``` -------------------------------- ### PostgrestClient OPTIONS JSDoc comment Source: https://github.com/supabase/postgrest-js/wiki/01.-Getting-Started JSDoc comment describing the OPTIONS object for PostgrestClient, including headers, query_params, and schema parameters. ```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 */ ``` -------------------------------- ### Basic select queries Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Basic select queries: retrieve all columns with '*' or specific columns with a comma-separated list. The select method defaults to all columns if no argument is provided. ```js // Getting all columns let { body: countries } = await client .from('countries') .select('*') // Getting specific columns let { body: countries } = await client .from('countries') .select('name') ``` -------------------------------- ### Update with Filter Source: https://github.com/supabase/postgrest-js/wiki/04.-PATCH Updates the 'message' column for rows where the current message equals 'Hello World 👋'. Requires at least one filter (e.g., .eq()) before or after .update(); otherwise, an error is returned. ```javascript let { status } = await client .from('messages') .eq('message', 'Hello World 👋') .update({ message: 'Goodbye World 👋' }) ``` -------------------------------- ### select(columnQuery = '*') Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Specifies which columns to retrieve from the table. ```APIDOC ## select(columnQuery = '*') ### Description Selects columns to retrieve from the table. Supports selecting all columns or specific columns, including columns from related foreign tables. ### Parameters - **columnQuery** (string) - Optional - A comma separated list of columns. Defaults to all columns. For foreign tables, use syntax like `name, cities {name}`. ### Example ```js let { body: countries } = await client .from('countries') .select('name') ``` ``` -------------------------------- ### order(columnName, sortAscending = false, nullsFirst = false) Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Orders the query results by a specified column. ```APIDOC ## order(columnName, sortAscending = false, nullsFirst = false) ### Description Orders the results by a specified column. Can be used on foreign table columns by prefixing with the foreign table name. ### Parameters - **columnName** (string) - Required - Name of the column to order by. - **sortAscending** (boolean) - Optional - Whether to sort ascending (true) or descending (false). Defaults to false. - **nullsFirst** (boolean) - Optional - Whether null values should be displayed first. Defaults to false. ### Example ```js let { body: countries } = await client .from('countries') .select('name') .order('name') ``` ``` -------------------------------- ### Order results Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Order results by a column. For foreign tables, prefix the column name with the foreign table name (e.g., 'cities.name'). The order method defaults to ascending and nulls first. ```js // 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') ``` -------------------------------- ### range(fromIndex, toIndex = null) Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Paginates the query by specifying a range of rows. ```APIDOC ## range(fromIndex, toIndex = null) ### Description Paginates the query by specifying a range of rows to return. ### Parameters - **fromIndex** (integer) - Required - Index of the first row to return. - **toIndex** (integer) - Optional - Index of the last row to return. If not provided, all remaining rows after fromIndex are returned. ### Example ```js let { body: countries } = await client .from('countries') .select('name') .range(0, 10) ``` ``` -------------------------------- ### Insert options object with upsert flag Source: https://github.com/supabase/postgrest-js/wiki/03.-POST Defines an options object for the insert method. Setting 'upsert' to true allows upserting, but requires primary key columns in the data and natural primary keys. ```javascript const options = { upsert: false // Set to true to allow upserting. } ``` -------------------------------- ### like(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters String search - case sensitive. ```APIDOC ## like(columnName, filterValue) ### Description String search filter that is case sensitive. Returns rows where the column matches the pattern. ### Method `like` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string) - Required - Pattern to match. ### Example ```js let { body: countries } = await client .from('countries') .like('name', '%Zeal%') .select('*') ``` ``` -------------------------------- ### single() Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Ensures the response is a single object, otherwise returns an error. ```APIDOC ## single() ### Description Sets the header that tells PostgREST to return a single object. If the query returns more than one row, an error with status 406 Not Acceptable is returned. ### Example ```js let { body: countries } = await client .from('countries') .select('name') .single() ``` ``` -------------------------------- ### Offset results Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Skip a number of rows before returning results. For foreign tables, pass the foreign table name as the second argument to apply the offset to that table. ```js // 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') ``` -------------------------------- ### is() - Exact equality (null, true, false) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is exactly equal to null, true, or false. filterValue can be null or boolean. ```javascript let { body: countries } = await client .from('countries') .is('name', null) .select('*') ``` -------------------------------- ### Query foreign table columns Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Query columns from a foreign table by nesting the related table's columns inside parentheses. Requires a foreign key constraint between the tables. ```js let { body: countries } = await client .from('countries') .select(` name, cities ( name ) `) ``` -------------------------------- ### Limit results Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Restrict the number of rows returned. For foreign tables, pass the foreign table name as the second argument to apply the limit to that table. ```js // 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') ``` -------------------------------- ### Fetch single row Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Set the header to request a single object. If the response is not a single object, PostgREST returns an error with 406 Not Acceptable. ```js let { body: countries } = await client .from('countries') .select('name') .single() ``` -------------------------------- ### rpc(functionName, functionParameters = {}) Source: https://github.com/supabase/postgrest-js/wiki/06.-Stored-Procedures Invokes a stored procedure (function) in the database. The function name is required, and parameters can be provided as an object or array. This method is used to execute database logic that rarely changes, such as password resets. ```APIDOC ## rpc(functionName, functionParameters = {}) ### Description Invokes a stored procedure (function) in the database. This is useful for executing logic that rarely changes, such as password resets and updates. ### Method RPC (Remote Procedure Call) ### Parameters - **functionName** (string) - Required - Name of the stored function in the database. - **functionParameters** (object | array) - Optional - Parameters to be passed to the stored function. ### Request Example ```js let cities = await client .rpc('echo_city', [ { name: 'The Shire' }, { name: 'Mordor' } ]) ``` ### Notes - General filters can be applied after invoking `.rpc()`. See [General Filters](https://github.com/supabase/postgrest-js/wiki/07.-General-Filters) for more details. ``` -------------------------------- ### cs(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Contains filter. ```APIDOC ## cs(columnName, filterValue) ### Description Contains filter. Returns rows where the column contains the provided value. ### Method `cs` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array | object) - Required - Value to check for containment. ### Example ```js let { body: countries } = await client .from('countries') .cs('main_exports', ['oil']) .select('*') ``` ``` -------------------------------- ### UPDATE /messages Source: https://github.com/supabase/postgrest-js/wiki/04.-PATCH This snippet documents the update operation for the postgrest-js client, including the required table name and data parameters, and the necessity of applying at least one filter. ```APIDOC ## [UPDATE] /messages ### Description Updates records in the 'messages' table with new values. Requires at least one filter to be applied before or after the update call. ### Method UPDATE ### Endpoint /messages ### Parameters #### Path Parameters - **tableName** (string) - Required - Name of the database table to update. #### Request Body - **data** (object) - Required - New record values. ### Request Example ```js let { status } = await client .from('messages') .eq('message', 'Hello World 👋') .update({ message: 'Goodbye World 👋' }) ``` ### Response #### Success Response (200) - **status** (number) - HTTP status code of the response. #### Response Example ```js let { status } = await client .from('messages') .eq('message', 'Hello World 👋') .update({ message: 'Goodbye World 👋' }) ``` ### Error Handling - **Error** - Occurs if no filter is applied before or after the update call. ``` -------------------------------- ### like() - Case sensitive string search Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column matches a pattern using SQL LIKE, case sensitive. filterValue is a string. ```javascript let { body: countries } = await client .from('countries') .like('name', '%Zeal%') .select('*') ``` -------------------------------- ### offset(criteria, foreignTableName = null) Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Skips a specified number of rows before returning results. ```APIDOC ## offset(criteria, foreignTableName = null) ### Description Sets the number of rows to skip before returning results. Can be applied to a foreign table by specifying the foreign table name. ### Parameters - **criteria** (number) - Required - Number of rows to skip. - **foreignTableName** (string) - Optional - Name of the foreign table to apply the offset on. ### Example ```js let { body: countries } = await client .from('countries') .select('*') .offset(1) ``` ``` -------------------------------- ### match(filterObject) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows that exactly match the specified filterObject. Equivalent to multiple filter('columnName', 'eq', criteria) calls. ```javascript let { body: countries } = await client .from('countries') .match({ 'continent': 'Asia' }) .select('*') ``` -------------------------------- ### is(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Exact equality (null, true, false). ```APIDOC ## is(columnName, filterValue) ### Description Exact equality filter for null, true, or false values. ### Method `is` ### 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('*') ``` ``` -------------------------------- ### match(filterObject) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows that exactly match the specified filterObject. Equivalent of multiple filter('columnName', 'eq', criteria). ```APIDOC ## match(filterObject) ### Description Finds rows that exactly match the specified filterObject. Equivalent of multiple filter('columnName', 'eq', criteria). ### Method match ### Parameters - **filterObject** (object) - Required - An object containing multiple columnNames as keys and their respective criteria to match as values. ### Request Example ```js let { body: countries } = await client .from('countries') .match({ 'continent': 'Asia' }) .select('*') ``` ``` -------------------------------- ### ilike(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters String search - case insensitive. ```APIDOC ## ilike(columnName, filterValue) ### Description String search filter that is case insensitive. Returns rows where the column matches the pattern. ### Method `ilike` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string) - Required - Pattern to match. ### Example ```js let { body: countries } = await client .from('countries') .ilike('name', '%Zeal%') .select('*') ``` ``` -------------------------------- ### Common filter pattern Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Shows the common signature for all filters: commonFilter(columnName, filterValue). ```javascript commonFilter(columnName, filterValue) ``` -------------------------------- ### filter(columnName, operator, criteria) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Applies a filter to the query based on a column, operator, and criteria. Filters can be chained together. ```APIDOC ## filter(columnName, operator, criteria) ### Description Applies a filter to the query based on a column, operator, and criteria. Filters can be chained together. ### Method filter ### Parameters - **columnName** (string) - Required - Name of the database column. - **operator** (string) - Required - Name of filter operator to be utilised. These can be found 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. ### Request Example ```js let { body: countries } = await client .from('countries') .filter('continent', 'eq', 'Asia') .select('*') ``` ``` -------------------------------- ### cd(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Contained in filter. ```APIDOC ## cd(columnName, filterValue) ### Description Contained in filter. Returns rows where the column is contained in the provided value. ### Method `cd` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array | object) - Required - Value to check for containment. ### Example ```js let { body: countries } = await client .from('countries') .cd('main_exports', ['cars', 'food', 'machine']) .select('*') ``` ``` -------------------------------- ### limit(criteria, foreignTableName = null) Source: https://github.com/supabase/postgrest-js/wiki/02.-GET Limits the number of rows returned by the query. ```APIDOC ## limit(criteria, foreignTableName = null) ### Description Restricts the number of rows returned. Can be applied to a foreign table by specifying the foreign table name. ### Parameters - **criteria** (number) - Required - Maximum number of rows to return. - **foreignTableName** (string) - Optional - Name of the foreign table to apply the limit on. ### Example ```js let { body: countries } = await client .from('countries') .select('*') .limit(1) ``` ``` -------------------------------- ### ilike() - Case insensitive string search Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column matches a pattern using ILIKE, case insensitive. filterValue is a string. ```javascript let { body: countries } = await client .from('countries') .ilike('name', '%Zeal%') .select('*') ``` -------------------------------- ### in(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters In list filter. ```APIDOC ## in(columnName, filterValue) ### Description Filters rows where the column value is in the provided list. ### Method `in` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array) - Required - List of values to match. ### Example ```js let { body: countries } = await client .from('countries') .in('name', ['China', 'France']) .select('*') ``` ``` -------------------------------- ### sl(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Strictly left filter. ```APIDOC ## sl(columnName, filterValue) ### Description Strictly left filter. Returns rows where the column range is strictly left of the provided range. ### Method `sl` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array) - Required - Array of two elements representing the range. Returns an error if length is not 2. ### Example ```js let { body: countries } = await client .from('countries') .sl('population_range_millions', [150, 250]) .select('*') ``` ``` -------------------------------- ### filter(columnName, operator, criteria) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filter rows based on a column, operator, and criteria. The operator can be one of the common filters like 'eq'. Filter can be chained with other filters. ```javascript let { body: countries } = await client .from('countries') .filter('continent', 'eq', 'Asia') .select('*') ``` -------------------------------- ### lte() - Less than or equal filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is less than or equal to the given value. filterValue can be string, integer, or boolean. ```javascript let { body: countries } = await client .from('countries') .lte('id', 20) .select('*') ``` -------------------------------- ### eq() - Equal filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column equals the given value. filterValue can be string, integer, or boolean. ```javascript let { body: countries } = await client .from('countries') .eq('name', 'New Zealand') .select('*') ``` -------------------------------- ### nxl() Does Not Extend Left Range Filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the range column does not extend to the left of the given range. The filterValue must be an array of length 2; otherwise an error is returned. ```javascript let { body: countries } = await client .from('countries') .nxl('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### ova(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Overlaps (for arrays). ```APIDOC ## ova(columnName, filterValue) ### Description Overlaps filter for arrays. Returns rows where the column array overlaps with the provided array. ### Method `ova` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array) - Required - Array to compare. ### Example ```js let { body: countries } = await client .from('countries') .ova('main_exports', ['computers', 'minerals']) .select('*') ``` ``` -------------------------------- ### Delete rows with filter using postgrest-js Source: https://github.com/supabase/postgrest-js/wiki/05.-DELETE Deletes rows from the 'messages' table where the 'message' column equals 'Goodbye World 👋'. The response status is destructured from the client result. At least one filter is required when using delete(); otherwise an error occurs. ```javascript let { status } = await client .from('messages') .eq('message', 'Goodbye World 👋') .delete() ``` -------------------------------- ### not(columnName, operator, criteria) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Reverse of .filter(). Returns rows that do not meet the specified criteria using the given column and operator. ```javascript let { body: countries } = await client .from('countries') .not('continent', 'eq', 'Asia') .select('*') ``` -------------------------------- ### neq() - Not equal filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is not equal to the given value. filterValue can be string, integer, or boolean. ```javascript let { body: countries } = await client .from('countries') .neq('name', 'New Zealand') .select('*') ``` -------------------------------- ### nxl() Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Does not extend to the left filter. Returns rows where the column value does not extend to the left of the given range. ```APIDOC ## nxl() ### Description Does not extend to the left filter. Returns rows where the column value does not extend to the left of the given range. ### Method nxl() ### Parameters - **column** (string) - Required - The column name to filter on. - **filterValue** (array) - Required - Array of two values representing the range. Must have length 2. ### Request Example ```js let { body: countries } = await client .from('countries') .nxl('population_range_millions', [150, 250]) .select('*') ``` ### Response Returns the filtered rows. ``` -------------------------------- ### phfts() - Full text search (phraseto_tsquery) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated column match phraseto_tsquery(queryText). filterValue is an object with queryText and optional config. ```javascript let { body: countries } = await client .from('characters') .phfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ```javascript /** * @param {string} queryText * Value to eventually compare to. * * @param {string?} config * Config to apply, if any. */ ``` -------------------------------- ### wfts() - Full text search (websearch_to_tsquery) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated column match websearch_to_tsquery(queryText). filterValue is an object with queryText and optional config. ```javascript let { body: countries } = await client .from('characters') .wfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ```javascript /** * @param {string} queryText * Value to eventually compare to. * * @param {string?} config * Config to apply, if any. */ ``` -------------------------------- ### lt() - Less than filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is less than the given value. filterValue can be string, integer, or boolean. ```javascript let { body: countries } = await client .from('countries') .lt('id', 20) .select('*') ``` -------------------------------- ### plfts() - Full text search (plainto_tsquery) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated column match plainto_tsquery(queryText). filterValue is an object with queryText and optional config. ```javascript let { body: countries } = await client .from('characters') .plfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ```javascript /** * @param {string} queryText * Value to eventually compare to. * * @param {string?} config * Config to apply, if any. */ ``` -------------------------------- ### neq(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is not equal to the given value. ```APIDOC ## neq(columnName, filterValue) ### Description Not equal filter. Returns rows where the column value is not equal to the provided value. ### Method `neq` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string | integer | boolean) - Required - Value to compare against. ### Example ```js let { body: countries } = await client .from('countries') .neq('name', 'New Zealand') .select('*') ``` ``` -------------------------------- ### not(columnName, operator, criteria) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Reverse of .filter(). Returns rows that do not meet the criteria specified using the columnName and operator provided. ```APIDOC ## not(columnName, operator, criteria) ### Description Reverse of .filter(). Returns rows that do not meet the criteria specified using the columnName and operator provided. ### Method not ### Parameters - **columnName** (string) - Required - Name of the database column. - **operator** (string) - Required - Name of filter operator to be utilised. These can be found 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. ### Request Example ```js let { body: countries } = await client .from('countries') .not('continent', 'eq', 'Asia') .select('*') ``` ``` -------------------------------- ### fts() - Full text search (to_tsquery) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated column match to_tsquery(queryText). filterValue is an object with queryText and optional config. ```javascript let { body: countries } = await client .from('characters') .fts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ```javascript /** * @param {string} queryText * Value to eventually compare to. * * @param {string?} config * Config to apply, if any. */ ``` -------------------------------- ### lt(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is less than the given value. ```APIDOC ## lt(columnName, filterValue) ### Description Less than filter. Returns rows where the column value is less than the provided value. ### Method `lt` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string | integer | boolean) - Required - Value to compare against. ### Example ```js let { body: countries } = await client .from('countries') .lt('id', 20) .select('*') ``` ``` -------------------------------- ### nxr() Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Does not extend to the right filter. Returns rows where the column value does not extend to the right of the given range. ```APIDOC ## nxr() ### Description Does not extend to the right filter. Returns rows where the column value does not extend to the right of the given range. ### Method nxr() ### Parameters - **column** (string) - Required - The column name to filter on. - **filterValue** (array) - Required - Array of two values representing the range. Must have length 2. ### Request Example ```js let { body: countries } = await client .from('countries') .nxr('population_range_millions', [150, 250]) .select('*') ``` ### Response Returns the filtered rows. ``` -------------------------------- ### gte() - Greater than or equal filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is greater than or equal to the given value. filterValue can be string, integer, or boolean. ```javascript let { body: countries } = await client .from('countries') .gte('id', 20) .select('*') ``` -------------------------------- ### lte(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is less than or equal to the given value. ```APIDOC ## lte(columnName, filterValue) ### Description Less than or equal filter. Returns rows where the column value is less than or equal to the provided value. ### Method `lte` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string | integer | boolean) - Required - Value to compare against. ### Example ```js let { body: countries } = await client .from('countries') .lte('id', 20) .select('*') ``` ``` -------------------------------- ### eq(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column equals the given value. ```APIDOC ## eq(columnName, filterValue) ### Description Equal filter. Returns rows where the column value equals the provided value. ### Method `eq` ### 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('*') ``` ``` -------------------------------- ### ovr(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Overlaps (for ranges). ```APIDOC ## ovr(columnName, filterValue) ### Description Overlaps filter for ranges. Returns rows where the column range overlaps with the provided range. ### Method `ovr` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (array) - Required - Array of two elements representing the range. Returns an error if length is not 2. ### Example ```js let { body: countries } = await client .from('countries') .ovr('population_range_millions', [150, 250]) .select('*') ``` ``` -------------------------------- ### nxr() Does Not Extend Right Range Filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the range column does not extend to the right of the given range. The filterValue must be an array of length 2; otherwise an error is returned. ```javascript let { body: countries } = await client .from('countries') .nxr('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### ova() - Overlaps (arrays) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column overlaps with the given array. filterValue is an array. ```javascript let { body: countries } = await client .from('countries') .ova('main_exports', ['computers', 'minerals']) .select('*') ``` -------------------------------- ### adj() Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Adjacent filter. Returns rows where the column value is adjacent to the given range. ```APIDOC ## adj() ### Description Adjacent filter. Returns rows where the column value is adjacent to the given range. ### Method adj() ### Parameters - **column** (string) - Required - The column name to filter on. - **filterValue** (array) - Required - Array of two values representing the range. Must have length 2. ### Request Example ```js let { body: countries } = await client .from('countries') .adj('population_range_millions', [70, 185]) .select('*') ``` ### Response Returns the filtered rows. ``` -------------------------------- ### cs() - Contains filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column contains the given value. filterValue can be an array or object. ```javascript let { body: countries } = await client .from('countries') .cs('main_exports', ['oil']) .select('*') ``` -------------------------------- ### gt(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is greater than the given value. ```APIDOC ## gt(columnName, filterValue) ### Description Greater than filter. Returns rows where the column value is greater than the provided value. ### Method `gt` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string | integer | boolean) - Required - Value to compare against. ### Example ```js let { body: countries } = await client .from('countries') .gt('id', 20) .select('*') ``` ``` -------------------------------- ### gte(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is greater than or equal to the given value. ```APIDOC ## gte(columnName, filterValue) ### Description Greater than or equal filter. Returns rows where the column value is greater than or equal to the provided value. ### Method `gte` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (string | integer | boolean) - Required - Value to compare against. ### Example ```js let { body: countries } = await client .from('countries') .gte('id', 20) .select('*') ``` ``` -------------------------------- ### in() - In list filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column value is in the given array. filterValue is an array. ```javascript let { body: countries } = await client .from('countries') .in('name', ['China', 'France']) .select('*') ``` -------------------------------- ### gt() - Greater than filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column is greater than the given value. filterValue can be string, integer, or boolean. ```javascript let { body: countries } = await client .from('countries') .gt('id', 20) .select('*') ``` -------------------------------- ### sr() Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Strictly right filter. Returns rows where the column value is strictly to the right of the given range. ```APIDOC ## sr() ### Description Strictly right filter. Returns rows where the column value is strictly to the right of the given range. ### Method sr() ### Parameters - **column** (string) - Required - The column name to filter on. - **filterValue** (array) - Required - Array of two values representing the range. Must have length 2. ### Request Example ```js let { body: countries } = await client .from('countries') .sr('population_range_millions', [150, 250]) .select('*') ``` ### Response Returns the filtered rows. ``` -------------------------------- ### sl() - Strictly left filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column range is strictly left of the given array. filterValue is an array of length 2; returns an error if length is not 2. ```javascript let { body: countries } = await client .from('countries') .sl('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### adj() Adjacent Range Filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the range column is adjacent to the given range. The filterValue must be an array of length 2; otherwise an error is returned. ```javascript let { body: countries } = await client .from('countries') .adj('population_range_millions', [70, 185]) .select('*') ``` -------------------------------- ### wfts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated columnName match websearch_to_tsquery(queryText). ```APIDOC ## wfts(columnName, filterValue) ### Description Full-text search filter that matches rows using websearch_to_tsquery. ### Method `wfts` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - Object with `queryText` (string) and optional `config` (string). ### Example ```js let { body: countries } = await client .from('characters') .wfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### phfts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated columnName match phraseto_tsquery(queryText). ```APIDOC ## phfts(columnName, filterValue) ### Description Full-text search filter that matches rows using phraseto_tsquery. ### Method `phfts` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - Object with `queryText` (string) and optional `config` (string). ### Example ```js let { body: countries } = await client .from('characters') .phfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### sr() Strictly Right Range Filter Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the range column is strictly to the right of the given range. The filterValue must be an array of length 2; otherwise an error is returned. ```javascript let { body: countries } = await client .from('countries') .sr('population_range_millions', [150, 250]) .select('*') ``` -------------------------------- ### fts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated columnName match to_tsquery(queryText). ```APIDOC ## fts(columnName, filterValue) ### Description Full-text search filter that matches rows using to_tsquery. ### Method `fts` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - Object with `queryText` (string) and optional `config` (string). ### Example ```js let { body: countries } = await client .from('characters') .fts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### plfts(columnName, filterValue) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Finds rows whose tsvector values on the stated columnName match plainto_tsquery(queryText). ```APIDOC ## plfts(columnName, filterValue) ### Description Full-text search filter that matches rows using plainto_tsquery. ### Method `plfts` ### Parameters - **columnName** (string) - Required - Name of the database column. - **filterValue** (object) - Required - Object with `queryText` (string) and optional `config` (string). ### Example ```js let { body: countries } = await client .from('characters') .plfts('catch_phrase', { queryText: 'The Fat Cats', config: 'english' }) .select('*') ``` ``` -------------------------------- ### ovr() - Overlaps (ranges) Source: https://github.com/supabase/postgrest-js/wiki/07.-General-Filters Filters rows where the column range overlaps with the given array. filterValue is an array of length 2; returns an error if length is not 2. ```javascript let { body: countries } = await client .from('countries') .ovr('population_range_millions', [150, 250]) .select('*') ```