Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Commit 2d1264e

Browse files
committed
fix(rpc): allow filters on rpc
1 parent d6b8816 commit 2d1264e

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/PostgrestClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PostgrestQueryBuilder from './lib/PostgrestQueryBuilder'
22
import PostgrestRpcBuilder from './lib/PostgrestRpcBuilder'
3-
import PostgrestTransformBuilder from './lib/PostgrestTransformBuilder'
3+
import PostgrestFilterBuilder from './lib/PostgrestFilterBuilder'
44

55
export default class PostgrestClient {
66
url: string
@@ -58,7 +58,7 @@ export default class PostgrestClient {
5858
}: {
5959
count?: null | 'exact' | 'planned' | 'estimated'
6060
} = {}
61-
): PostgrestTransformBuilder<T> {
61+
): PostgrestFilterBuilder<T> {
6262
const url = `${this.url}/rpc/${fn}`
6363
return new PostgrestRpcBuilder<T>(url, {
6464
headers: this.headers,

src/lib/PostgrestRpcBuilder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { PostgrestBuilder } from './types'
2-
import PostgrestTransformBuilder from './PostgrestTransformBuilder'
2+
import PostgrestFilterBuilder from './PostgrestFilterBuilder'
33

44
export default class PostgrestRpcBuilder<T> extends PostgrestBuilder<T> {
55
constructor(
@@ -22,7 +22,7 @@ export default class PostgrestRpcBuilder<T> extends PostgrestBuilder<T> {
2222
}: {
2323
count?: null | 'exact' | 'planned' | 'estimated'
2424
} = {}
25-
): PostgrestTransformBuilder<T> {
25+
): PostgrestFilterBuilder<T> {
2626
this.method = 'POST'
2727
this.body = params
2828

@@ -31,6 +31,6 @@ export default class PostgrestRpcBuilder<T> extends PostgrestBuilder<T> {
3131
else this.headers['Prefer'] = `count=${count}`
3232
}
3333

34-
return new PostgrestTransformBuilder(this)
34+
return new PostgrestFilterBuilder(this)
3535
}
3636
}

test/filters.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,3 +743,19 @@ test('match', async () => {
743743
}
744744
`)
745745
})
746+
747+
test('filter on stored procedure', async () => {
748+
const res = await postgrest
749+
.rpc('get_username_and_status', { name_param: 'supabot' })
750+
.neq('status', 'ONLINE')
751+
expect(res).toMatchInlineSnapshot(`
752+
Object {
753+
"body": Array [],
754+
"count": null,
755+
"data": Array [],
756+
"error": null,
757+
"status": 200,
758+
"statusText": "OK",
759+
}
760+
`)
761+
})

0 commit comments

Comments
 (0)