@@ -96,6 +96,20 @@ export default class PostgrestQueryBuilder<
96
96
} as unknown as PostgrestBuilder < ResultOne [ ] > )
97
97
}
98
98
99
+ // TODO(v3): Make `defaultToNull` consistent for both single & bulk inserts.
100
+ insert < Row extends Relation extends { Insert : unknown } ? Relation [ 'Insert' ] : never > (
101
+ values : Row ,
102
+ options ?: {
103
+ count ?: 'exact' | 'planned' | 'estimated'
104
+ }
105
+ ) : PostgrestFilterBuilder < Schema , Relation [ 'Row' ] , null , Relationships >
106
+ insert < Row extends Relation extends { Insert : unknown } ? Relation [ 'Insert' ] : never > (
107
+ values : Row [ ] ,
108
+ options ?: {
109
+ count ?: 'exact' | 'planned' | 'estimated'
110
+ defaultToNull ?: boolean
111
+ }
112
+ ) : PostgrestFilterBuilder < Schema , Relation [ 'Row' ] , null , Relationships >
99
113
/**
100
114
* Perform an INSERT into the table or view.
101
115
*
@@ -119,7 +133,8 @@ export default class PostgrestQueryBuilder<
119
133
* numbers.
120
134
*
121
135
* @param options.defaultToNull - Make missing fields default to `null`.
122
- * Otherwise, use the default value for the column.
136
+ * Otherwise, use the default value for the column. Only applies for bulk
137
+ * inserts.
123
138
*/
124
139
insert < Row extends Relation extends { Insert : unknown } ? Relation [ 'Insert' ] : never > (
125
140
values : Row | Row [ ] ,
@@ -164,6 +179,24 @@ export default class PostgrestQueryBuilder<
164
179
} as unknown as PostgrestBuilder < null > )
165
180
}
166
181
182
+ // TODO(v3): Make `defaultToNull` consistent for both single & bulk upserts.
183
+ upsert < Row extends Relation extends { Insert : unknown } ? Relation [ 'Insert' ] : never > (
184
+ values : Row ,
185
+ options ?: {
186
+ onConflict ?: string
187
+ ignoreDuplicates ?: boolean
188
+ count ?: 'exact' | 'planned' | 'estimated'
189
+ }
190
+ ) : PostgrestFilterBuilder < Schema , Relation [ 'Row' ] , null , Relationships >
191
+ upsert < Row extends Relation extends { Insert : unknown } ? Relation [ 'Insert' ] : never > (
192
+ values : Row [ ] ,
193
+ options ?: {
194
+ onConflict ?: string
195
+ ignoreDuplicates ?: boolean
196
+ count ?: 'exact' | 'planned' | 'estimated'
197
+ defaultToNull ?: boolean
198
+ }
199
+ ) : PostgrestFilterBuilder < Schema , Relation [ 'Row' ] , null , Relationships >
167
200
/**
168
201
* Perform an UPSERT on the table or view. Depending on the column(s) passed
169
202
* to `onConflict`, `.upsert()` allows you to perform the equivalent of
@@ -200,7 +233,7 @@ export default class PostgrestQueryBuilder<
200
233
* @param options.defaultToNull - Make missing fields default to `null`.
201
234
* Otherwise, use the default value for the column. This only applies when
202
235
* inserting new rows, not when merging with existing rows under
203
- * `ignoreDuplicates: false`.
236
+ * `ignoreDuplicates: false`. This also only applies when doing bulk upserts.
204
237
*/
205
238
upsert < Row extends Relation extends { Insert : unknown } ? Relation [ 'Insert' ] : never > (
206
239
values : Row | Row [ ] ,
0 commit comments