@@ -18,9 +18,9 @@ public class PostgrestQueryBuilder: PostgrestBuilder {
18
18
)
19
19
}
20
20
21
- public func insert( values: Any , upsert: Bool = false , onConflict: String ? = nil ) -> PostgrestBuilder {
21
+ public func insert( values: Any , upsert: Bool = false , onConflict: String ? = nil , returning : PostgrestReturningOptions = . representation ) -> PostgrestBuilder {
22
22
method = " POST "
23
- headers [ " Prefer " ] = upsert ? " return=representation ,resolution=merge-duplicates " : " return=representation "
23
+ headers [ " Prefer " ] = upsert ? " return= \( returning . rawValue ) ,resolution=merge-duplicates " : " return= \( returning . rawValue ) "
24
24
if let onConflict = onConflict {
25
25
appendSearchParams ( name: " on_conflict " , value: onConflict)
26
26
}
@@ -29,9 +29,9 @@ public class PostgrestQueryBuilder: PostgrestBuilder {
29
29
return self
30
30
}
31
31
32
- public func upsert( values: Any , onConflict: String ? = nil ) -> PostgrestBuilder {
32
+ public func upsert( values: Any , onConflict: String ? = nil , returning : PostgrestReturningOptions = . representation ) -> PostgrestBuilder {
33
33
method = " POST "
34
- headers [ " Prefer " ] = " return=representation ,resolution=merge-duplicates "
34
+ headers [ " Prefer " ] = " return= \( returning . rawValue ) ,resolution=merge-duplicates "
35
35
if let onConflict = onConflict {
36
36
appendSearchParams ( name: " on_conflict " , value: onConflict)
37
37
}
@@ -40,19 +40,19 @@ public class PostgrestQueryBuilder: PostgrestBuilder {
40
40
return self
41
41
}
42
42
43
- public func update( values: Any ) -> PostgrestFilterBuilder {
43
+ public func update( values: Any , returning : PostgrestReturningOptions = . representation ) -> PostgrestFilterBuilder {
44
44
method = " PATCH "
45
- headers [ " Prefer " ] = " return=representation "
45
+ headers [ " Prefer " ] = " return= \( returning . rawValue ) "
46
46
body = values
47
47
return PostgrestFilterBuilder (
48
48
url: url, queryParams: queryParams, headers: headers, schema: schema, method: method,
49
49
body: body
50
50
)
51
51
}
52
52
53
- public func delete( ) -> PostgrestFilterBuilder {
53
+ public func delete( returning : PostgrestReturningOptions = . representation ) -> PostgrestFilterBuilder {
54
54
method = " DELETE "
55
- headers [ " Prefer " ] = " return=representation "
55
+ headers [ " Prefer " ] = " return= \( returning . rawValue ) "
56
56
return PostgrestFilterBuilder (
57
57
url: url, queryParams: queryParams, headers: headers, schema: schema, method: method,
58
58
body: body
0 commit comments