|
1 | 1 | import PostgrestBuilder from './PostgrestBuilder'
|
2 | 2 | import { InvalidMethodError } from './PostgrestFilterBuilder'
|
3 | 3 | import { GetResult } from './select-query-parser/result'
|
4 |
| -import { GenericSchema, CheckMatchingArrayTypes, ClientServerOptions } from './types' |
| 4 | +import { |
| 5 | + GenericSchema, |
| 6 | + CheckMatchingArrayTypes, |
| 7 | + ClientServerOptions, |
| 8 | + MaxAffectedEnabled, |
| 9 | +} from './types' |
5 | 10 |
|
6 | 11 | export default class PostgrestTransformBuilder<
|
7 | 12 | ClientOptions extends ClientServerOptions,
|
@@ -346,15 +351,15 @@ export default class PostgrestTransformBuilder<
|
346 | 351 | *
|
347 | 352 | * @param value - The maximum number of rows that can be affected
|
348 | 353 | */
|
349 |
| - maxAffected(value: number): ClientOptions['postgrestVersion'] extends 13 |
| 354 | + maxAffected(value: number): MaxAffectedEnabled<ClientOptions['postgrestVersion']> extends true |
350 | 355 | ? // TODO: update the RPC case to only work on RPC that returns SETOF rows
|
351 | 356 | Method extends 'PATCH' | 'DELETE' | 'RPC'
|
352 | 357 | ? this
|
353 | 358 | : InvalidMethodError<'maxAffected method only available on update or delete'>
|
354 | 359 | : InvalidMethodError<'maxAffected method only available on postgrest 13+'> {
|
355 | 360 | this.headers.append('Prefer', 'handling=strict')
|
356 | 361 | this.headers.append('Prefer', `max-affected=${value}`)
|
357 |
| - return this as unknown as ClientOptions['postgrestVersion'] extends 13 |
| 362 | + return this as unknown as MaxAffectedEnabled<ClientOptions['postgrestVersion']> extends true |
358 | 363 | ? Method extends 'PATCH' | 'DELETE' | 'RPC'
|
359 | 364 | ? this
|
360 | 365 | : InvalidMethodError<'maxAffected method only available on update or delete'>
|
|
0 commit comments