@supabase/postgrest-js
Advanced tools
Comparing version 0.26.0 to 0.26.1
import PostgrestTransformBuilder from './PostgrestTransformBuilder'; | ||
/** | ||
* Filters | ||
*/ | ||
declare type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'sl' | 'sr' | 'nxl' | 'nxr' | 'adj' | 'ov' | 'fts' | 'plfts' | 'phfts' | 'wfts'; | ||
@@ -3,0 +6,0 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder<T> { |
@@ -7,6 +7,2 @@ "use strict"; | ||
const PostgrestTransformBuilder_1 = __importDefault(require("./PostgrestTransformBuilder")); | ||
/** | ||
* Filters | ||
*/ | ||
const cleanFilterArray = (filter) => filter.map((s) => `${s}`).join(','); | ||
class PostgrestFilterBuilder extends PostgrestTransformBuilder_1.default { | ||
@@ -142,3 +138,13 @@ /** | ||
in(column, values) { | ||
this.url.searchParams.append(`${column}`, `in.(${cleanFilterArray(values)})`); | ||
const cleanedValues = values | ||
.map((s) => { | ||
// handle postgrest reserved characters | ||
// https://postgrest.org/en/v7.0.0/api.html#reserved-characters | ||
if (typeof s === 'string' && new RegExp('[,()]').test(s)) | ||
return `"${s}"`; | ||
else | ||
return `${s}`; | ||
}) | ||
.join(','); | ||
this.url.searchParams.append(`${column}`, `in.(${cleanedValues})`); | ||
return this; | ||
@@ -161,3 +167,3 @@ } | ||
// array | ||
this.url.searchParams.append(`${column}`, `cs.{${cleanFilterArray(value)}}`); | ||
this.url.searchParams.append(`${column}`, `cs.{${value.join(',')}}`); | ||
} | ||
@@ -184,3 +190,3 @@ else { | ||
// array | ||
this.url.searchParams.append(`${column}`, `cd.{${cleanFilterArray(value)}}`); | ||
this.url.searchParams.append(`${column}`, `cd.{${value.join(',')}}`); | ||
} | ||
@@ -262,3 +268,3 @@ else { | ||
// array | ||
this.url.searchParams.append(`${column}`, `ov.{${cleanFilterArray(value)}}`); | ||
this.url.searchParams.append(`${column}`, `ov.{${value.join(',')}}`); | ||
} | ||
@@ -265,0 +271,0 @@ return this; |
import PostgrestTransformBuilder from './PostgrestTransformBuilder'; | ||
/** | ||
* Filters | ||
*/ | ||
declare type FilterOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'like' | 'ilike' | 'is' | 'in' | 'cs' | 'cd' | 'sl' | 'sr' | 'nxl' | 'nxr' | 'adj' | 'ov' | 'fts' | 'plfts' | 'phfts' | 'wfts'; | ||
@@ -3,0 +6,0 @@ export default class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder<T> { |
import PostgrestTransformBuilder from './PostgrestTransformBuilder'; | ||
/** | ||
* Filters | ||
*/ | ||
const cleanFilterArray = (filter) => filter.map((s) => `${s}`).join(','); | ||
export default class PostgrestFilterBuilder extends PostgrestTransformBuilder { | ||
@@ -136,3 +132,13 @@ /** | ||
in(column, values) { | ||
this.url.searchParams.append(`${column}`, `in.(${cleanFilterArray(values)})`); | ||
const cleanedValues = values | ||
.map((s) => { | ||
// handle postgrest reserved characters | ||
// https://postgrest.org/en/v7.0.0/api.html#reserved-characters | ||
if (typeof s === 'string' && new RegExp('[,()]').test(s)) | ||
return `"${s}"`; | ||
else | ||
return `${s}`; | ||
}) | ||
.join(','); | ||
this.url.searchParams.append(`${column}`, `in.(${cleanedValues})`); | ||
return this; | ||
@@ -155,3 +161,3 @@ } | ||
// array | ||
this.url.searchParams.append(`${column}`, `cs.{${cleanFilterArray(value)}}`); | ||
this.url.searchParams.append(`${column}`, `cs.{${value.join(',')}}`); | ||
} | ||
@@ -178,3 +184,3 @@ else { | ||
// array | ||
this.url.searchParams.append(`${column}`, `cd.{${cleanFilterArray(value)}}`); | ||
this.url.searchParams.append(`${column}`, `cd.{${value.join(',')}}`); | ||
} | ||
@@ -256,3 +262,3 @@ else { | ||
// array | ||
this.url.searchParams.append(`${column}`, `ov.{${cleanFilterArray(value)}}`); | ||
this.url.searchParams.append(`${column}`, `ov.{${value.join(',')}}`); | ||
} | ||
@@ -259,0 +265,0 @@ return this; |
{ | ||
"name": "@supabase/postgrest-js", | ||
"version": "0.26.0", | ||
"version": "0.26.1", | ||
"description": "Isomorphic PostgREST client", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137133
2253