Skip to content

Commit f39dc34

Browse files
committed
chore: move maxAffected to PostgrestTransformBuilder
1 parent fe3e80f commit f39dc34

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

src/PostgrestFilterBuilder.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -601,26 +601,4 @@ export default class PostgrestFilterBuilder<
601601
this.url.searchParams.append(column, `${operator}.${value}`)
602602
return this
603603
}
604-
605-
/**
606-
* Set the maximum number of rows that can be affected by the query.
607-
* Only available in PostgREST v13+ and only works with PATCH and DELETE methods.
608-
*
609-
* @param value - The maximum number of rows that can be affected
610-
*/
611-
maxAffected(
612-
value: number
613-
): ClientOptions['postgrestVersion'] extends 13
614-
? Method extends 'PATCH' | 'DELETE'
615-
? this
616-
: InvalidMethodError<'maxAffected method only available on update or delete'>
617-
: InvalidMethodError<'maxAffected method only available on postgrest 13+'> {
618-
this.headers.append('Prefer', 'handling=strict')
619-
this.headers.append('Prefer', `max-affected=${value}`)
620-
return this as unknown as ClientOptions['postgrestVersion'] extends 13
621-
? Method extends 'PATCH' | 'DELETE'
622-
? this
623-
: InvalidMethodError<'maxAffected method only available on update or delete'>
624-
: InvalidMethodError<'maxAffected method only available on postgrest 13+'>
625-
}
626604
}

src/PostgrestTransformBuilder.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import PostgrestBuilder from './PostgrestBuilder'
2+
import { InvalidMethodError } from './PostgrestFilterBuilder'
23
import { GetResult } from './select-query-parser/result'
34
import { GenericSchema, CheckMatchingArrayTypes, ClientServerOptions } from './types'
45

@@ -338,4 +339,26 @@ export default class PostgrestTransformBuilder<
338339
Method
339340
>
340341
}
342+
343+
/**
344+
* Set the maximum number of rows that can be affected by the query.
345+
* Only available in PostgREST v13+ and only works with PATCH and DELETE methods.
346+
*
347+
* @param value - The maximum number of rows that can be affected
348+
*/
349+
maxAffected(
350+
value: number
351+
): ClientOptions['postgrestVersion'] extends 13
352+
? Method extends 'PATCH' | 'DELETE'
353+
? this
354+
: InvalidMethodError<'maxAffected method only available on update or delete'>
355+
: InvalidMethodError<'maxAffected method only available on postgrest 13+'> {
356+
this.headers.append('Prefer', 'handling=strict')
357+
this.headers.append('Prefer', `max-affected=${value}`)
358+
return this as unknown as ClientOptions['postgrestVersion'] extends 13
359+
? Method extends 'PATCH' | 'DELETE'
360+
? this
361+
: InvalidMethodError<'maxAffected method only available on update or delete'>
362+
: InvalidMethodError<'maxAffected method only available on postgrest 13+'>
363+
}
341364
}

0 commit comments

Comments
 (0)