drizzle-orm 0.29.3 → 0.29.4-b475b53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -141
- package/alias.cjs.map +1 -1
- package/alias.js.map +1 -1
- package/aws-data-api/pg/session.cjs +2 -2
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +3 -3
- package/aws-data-api/pg/session.d.ts +3 -3
- package/aws-data-api/pg/session.js +4 -4
- package/aws-data-api/pg/session.js.map +1 -1
- package/d1/session.cjs +3 -3
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +1 -1
- package/d1/session.d.ts +1 -1
- package/d1/session.js +4 -4
- package/d1/session.js.map +1 -1
- package/libsql/session.cjs +1 -1
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.js +1 -1
- package/libsql/session.js.map +1 -1
- package/neon-http/driver.cjs +13 -1
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +8 -3
- package/neon-http/driver.d.ts +8 -3
- package/neon-http/driver.js +13 -5
- package/neon-http/driver.js.map +1 -1
- package/neon-http/session.cjs +46 -28
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +16 -12
- package/neon-http/session.d.ts +16 -12
- package/neon-http/session.js +47 -29
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/session.cjs +12 -12
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +5 -5
- package/neon-serverless/session.d.ts +5 -5
- package/neon-serverless/session.js +13 -13
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/session.cjs +12 -12
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +5 -5
- package/node-postgres/session.d.ts +5 -5
- package/node-postgres/session.js +13 -13
- package/node-postgres/session.js.map +1 -1
- package/package.json +13 -1
- package/pg-core/db.cjs +14 -1
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.js +14 -1
- package/pg-core/db.js.map +1 -1
- package/pg-core/query-builders/delete.cjs +11 -10
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +8 -6
- package/pg-core/query-builders/delete.d.ts +8 -6
- package/pg-core/query-builders/delete.js +11 -10
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +15 -14
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +8 -6
- package/pg-core/query-builders/insert.d.ts +8 -6
- package/pg-core/query-builders/insert.js +15 -14
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/query.cjs +1 -0
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +9 -6
- package/pg-core/query-builders/query.d.ts +9 -6
- package/pg-core/query-builders/query.js +1 -0
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/query-builders/raw.cjs +53 -0
- package/pg-core/query-builders/raw.cjs.map +1 -0
- package/pg-core/query-builders/raw.d.cts +22 -0
- package/pg-core/query-builders/raw.d.ts +22 -0
- package/pg-core/query-builders/raw.js +29 -0
- package/pg-core/query-builders/raw.js.map +1 -0
- package/pg-core/query-builders/refresh-materialized-view.cjs +1 -0
- package/pg-core/query-builders/refresh-materialized-view.cjs.map +1 -1
- package/pg-core/query-builders/refresh-materialized-view.d.cts +10 -6
- package/pg-core/query-builders/refresh-materialized-view.d.ts +10 -6
- package/pg-core/query-builders/refresh-materialized-view.js +1 -0
- package/pg-core/query-builders/refresh-materialized-view.js.map +1 -1
- package/pg-core/query-builders/select.cjs +86 -85
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +5 -4
- package/pg-core/query-builders/select.d.ts +5 -4
- package/pg-core/query-builders/select.js +86 -85
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +2 -2
- package/pg-core/query-builders/select.types.d.ts +2 -2
- package/pg-core/query-builders/update.cjs +9 -8
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +7 -5
- package/pg-core/query-builders/update.d.ts +7 -5
- package/pg-core/query-builders/update.js +9 -8
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs +14 -5
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +7 -2
- package/pg-core/session.d.ts +7 -2
- package/pg-core/session.js +12 -3
- package/pg-core/session.js.map +1 -1
- package/pg-proxy/session.cjs +2 -2
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +1 -1
- package/pg-proxy/session.d.ts +1 -1
- package/pg-proxy/session.js +2 -2
- package/pg-proxy/session.js.map +1 -1
- package/postgres-js/session.cjs +11 -11
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +5 -5
- package/postgres-js/session.d.ts +5 -5
- package/postgres-js/session.js +12 -12
- package/postgres-js/session.js.map +1 -1
- package/runnable-query.cjs.map +1 -1
- package/runnable-query.d.cts +0 -2
- package/runnable-query.d.ts +0 -2
- package/sql/sql.cjs +0 -8
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +1 -1
- package/sql/sql.d.ts +1 -1
- package/sql/sql.js +0 -8
- package/sql/sql.js.map +1 -1
- package/sqlite-core/db.cjs +53 -43
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +3 -0
- package/sqlite-core/db.d.ts +3 -0
- package/sqlite-core/db.js +53 -43
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs +20 -16
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +3 -3
- package/sqlite-core/query-builders/delete.d.ts +3 -3
- package/sqlite-core/query-builders/delete.js +20 -16
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs +23 -19
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +1 -1
- package/sqlite-core/query-builders/insert.d.ts +1 -1
- package/sqlite-core/query-builders/insert.js +23 -19
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +8 -4
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.js +8 -4
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/raw.cjs +9 -17
- package/sqlite-core/query-builders/raw.cjs.map +1 -1
- package/sqlite-core/query-builders/raw.d.cts +10 -6
- package/sqlite-core/query-builders/raw.d.ts +10 -6
- package/sqlite-core/query-builders/raw.js +9 -17
- package/sqlite-core/query-builders/raw.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs +78 -74
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +7 -7
- package/sqlite-core/query-builders/select.d.ts +7 -7
- package/sqlite-core/query-builders/select.js +78 -74
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs +17 -13
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +1 -1
- package/sqlite-core/query-builders/update.d.ts +1 -1
- package/sqlite-core/query-builders/update.js +17 -13
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/vercel-postgres/session.cjs +6 -6
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +4 -4
- package/vercel-postgres/session.d.ts +4 -4
- package/vercel-postgres/session.js +7 -7
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -147,22 +147,22 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Executes a `left join` operation by adding another table to the current query.
|
|
150
|
-
*
|
|
150
|
+
*
|
|
151
151
|
* Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.
|
|
152
|
-
*
|
|
152
|
+
*
|
|
153
153
|
* See docs: {@link https://orm.drizzle.team/docs/joins#left-join}
|
|
154
|
-
*
|
|
154
|
+
*
|
|
155
155
|
* @param table the table to join.
|
|
156
156
|
* @param on the `on` clause.
|
|
157
|
-
*
|
|
157
|
+
*
|
|
158
158
|
* @example
|
|
159
|
-
*
|
|
159
|
+
*
|
|
160
160
|
* ```ts
|
|
161
161
|
* // Select all users and their pets
|
|
162
162
|
* const usersWithPets: { user: User; pets: Pet | null }[] = await db.select()
|
|
163
163
|
* .from(users)
|
|
164
164
|
* .leftJoin(pets, eq(users.id, pets.ownerId))
|
|
165
|
-
*
|
|
165
|
+
*
|
|
166
166
|
* // Select userId and petId
|
|
167
167
|
* const usersIdsAndPetIds: { userId: number; petId: number | null }[] = await db.select({
|
|
168
168
|
* userId: users.id,
|
|
@@ -175,22 +175,22 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
175
175
|
leftJoin = this.createJoin("left");
|
|
176
176
|
/**
|
|
177
177
|
* Executes a `right join` operation by adding another table to the current query.
|
|
178
|
-
*
|
|
178
|
+
*
|
|
179
179
|
* Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.
|
|
180
|
-
*
|
|
180
|
+
*
|
|
181
181
|
* See docs: {@link https://orm.drizzle.team/docs/joins#right-join}
|
|
182
|
-
*
|
|
182
|
+
*
|
|
183
183
|
* @param table the table to join.
|
|
184
184
|
* @param on the `on` clause.
|
|
185
|
-
*
|
|
185
|
+
*
|
|
186
186
|
* @example
|
|
187
|
-
*
|
|
187
|
+
*
|
|
188
188
|
* ```ts
|
|
189
189
|
* // Select all users and their pets
|
|
190
190
|
* const usersWithPets: { user: User | null; pets: Pet }[] = await db.select()
|
|
191
191
|
* .from(users)
|
|
192
192
|
* .rightJoin(pets, eq(users.id, pets.ownerId))
|
|
193
|
-
*
|
|
193
|
+
*
|
|
194
194
|
* // Select userId and petId
|
|
195
195
|
* const usersIdsAndPetIds: { userId: number | null; petId: number }[] = await db.select({
|
|
196
196
|
* userId: users.id,
|
|
@@ -203,22 +203,22 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
203
203
|
rightJoin = this.createJoin("right");
|
|
204
204
|
/**
|
|
205
205
|
* Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.
|
|
206
|
-
*
|
|
206
|
+
*
|
|
207
207
|
* Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.
|
|
208
|
-
*
|
|
208
|
+
*
|
|
209
209
|
* See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}
|
|
210
|
-
*
|
|
210
|
+
*
|
|
211
211
|
* @param table the table to join.
|
|
212
212
|
* @param on the `on` clause.
|
|
213
|
-
*
|
|
213
|
+
*
|
|
214
214
|
* @example
|
|
215
|
-
*
|
|
215
|
+
*
|
|
216
216
|
* ```ts
|
|
217
217
|
* // Select all users and their pets
|
|
218
218
|
* const usersWithPets: { user: User; pets: Pet }[] = await db.select()
|
|
219
219
|
* .from(users)
|
|
220
220
|
* .innerJoin(pets, eq(users.id, pets.ownerId))
|
|
221
|
-
*
|
|
221
|
+
*
|
|
222
222
|
* // Select userId and petId
|
|
223
223
|
* const usersIdsAndPetIds: { userId: number; petId: number }[] = await db.select({
|
|
224
224
|
* userId: users.id,
|
|
@@ -231,22 +231,22 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
231
231
|
innerJoin = this.createJoin("inner");
|
|
232
232
|
/**
|
|
233
233
|
* Executes a `full join` operation by combining rows from two tables into a new table.
|
|
234
|
-
*
|
|
234
|
+
*
|
|
235
235
|
* Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.
|
|
236
|
-
*
|
|
236
|
+
*
|
|
237
237
|
* See docs: {@link https://orm.drizzle.team/docs/joins#full-join}
|
|
238
|
-
*
|
|
238
|
+
*
|
|
239
239
|
* @param table the table to join.
|
|
240
240
|
* @param on the `on` clause.
|
|
241
|
-
*
|
|
241
|
+
*
|
|
242
242
|
* @example
|
|
243
|
-
*
|
|
243
|
+
*
|
|
244
244
|
* ```ts
|
|
245
245
|
* // Select all users and their pets
|
|
246
246
|
* const usersWithPets: { user: User | null; pets: Pet | null }[] = await db.select()
|
|
247
247
|
* .from(users)
|
|
248
248
|
* .fullJoin(pets, eq(users.id, pets.ownerId))
|
|
249
|
-
*
|
|
249
|
+
*
|
|
250
250
|
* // Select userId and petId
|
|
251
251
|
* const usersIdsAndPetIds: { userId: number | null; petId: number | null }[] = await db.select({
|
|
252
252
|
* userId: users.id,
|
|
@@ -271,13 +271,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Adds `union` set operator to the query.
|
|
274
|
-
*
|
|
274
|
+
*
|
|
275
275
|
* Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.
|
|
276
|
-
*
|
|
276
|
+
*
|
|
277
277
|
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union}
|
|
278
|
-
*
|
|
278
|
+
*
|
|
279
279
|
* @example
|
|
280
|
-
*
|
|
280
|
+
*
|
|
281
281
|
* ```ts
|
|
282
282
|
* // Select all unique names from customers and users tables
|
|
283
283
|
* await db.select({ name: users.name })
|
|
@@ -287,9 +287,9 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
287
287
|
* );
|
|
288
288
|
* // or
|
|
289
289
|
* import { union } from 'drizzle-orm/pg-core'
|
|
290
|
-
*
|
|
290
|
+
*
|
|
291
291
|
* await union(
|
|
292
|
-
* db.select({ name: users.name }).from(users),
|
|
292
|
+
* db.select({ name: users.name }).from(users),
|
|
293
293
|
* db.select({ name: customers.name }).from(customers)
|
|
294
294
|
* );
|
|
295
295
|
* ```
|
|
@@ -297,13 +297,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
297
297
|
union = this.createSetOperator("union", false);
|
|
298
298
|
/**
|
|
299
299
|
* Adds `union all` set operator to the query.
|
|
300
|
-
*
|
|
300
|
+
*
|
|
301
301
|
* Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.
|
|
302
|
-
*
|
|
302
|
+
*
|
|
303
303
|
* See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}
|
|
304
|
-
*
|
|
304
|
+
*
|
|
305
305
|
* @example
|
|
306
|
-
*
|
|
306
|
+
*
|
|
307
307
|
* ```ts
|
|
308
308
|
* // Select all transaction ids from both online and in-store sales
|
|
309
309
|
* await db.select({ transaction: onlineSales.transactionId })
|
|
@@ -313,7 +313,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
313
313
|
* );
|
|
314
314
|
* // or
|
|
315
315
|
* import { unionAll } from 'drizzle-orm/pg-core'
|
|
316
|
-
*
|
|
316
|
+
*
|
|
317
317
|
* await unionAll(
|
|
318
318
|
* db.select({ transaction: onlineSales.transactionId }).from(onlineSales),
|
|
319
319
|
* db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)
|
|
@@ -323,13 +323,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
323
323
|
unionAll = this.createSetOperator("union", true);
|
|
324
324
|
/**
|
|
325
325
|
* Adds `intersect` set operator to the query.
|
|
326
|
-
*
|
|
326
|
+
*
|
|
327
327
|
* Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.
|
|
328
|
-
*
|
|
328
|
+
*
|
|
329
329
|
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}
|
|
330
|
-
*
|
|
330
|
+
*
|
|
331
331
|
* @example
|
|
332
|
-
*
|
|
332
|
+
*
|
|
333
333
|
* ```ts
|
|
334
334
|
* // Select course names that are offered in both departments A and B
|
|
335
335
|
* await db.select({ courseName: depA.courseName })
|
|
@@ -339,7 +339,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
339
339
|
* );
|
|
340
340
|
* // or
|
|
341
341
|
* import { intersect } from 'drizzle-orm/pg-core'
|
|
342
|
-
*
|
|
342
|
+
*
|
|
343
343
|
* await intersect(
|
|
344
344
|
* db.select({ courseName: depA.courseName }).from(depA),
|
|
345
345
|
* db.select({ courseName: depB.courseName }).from(depB)
|
|
@@ -349,30 +349,30 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
349
349
|
intersect = this.createSetOperator("intersect", false);
|
|
350
350
|
/**
|
|
351
351
|
* Adds `intersect all` set operator to the query.
|
|
352
|
-
*
|
|
352
|
+
*
|
|
353
353
|
* Calling this method will retain only the rows that are present in both result sets including all duplicates.
|
|
354
|
-
*
|
|
354
|
+
*
|
|
355
355
|
* See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}
|
|
356
|
-
*
|
|
356
|
+
*
|
|
357
357
|
* @example
|
|
358
|
-
*
|
|
358
|
+
*
|
|
359
359
|
* ```ts
|
|
360
360
|
* // Select all products and quantities that are ordered by both regular and VIP customers
|
|
361
|
-
* await db.select({
|
|
362
|
-
* productId: regularCustomerOrders.productId,
|
|
361
|
+
* await db.select({
|
|
362
|
+
* productId: regularCustomerOrders.productId,
|
|
363
363
|
* quantityOrdered: regularCustomerOrders.quantityOrdered
|
|
364
364
|
* })
|
|
365
365
|
* .from(regularCustomerOrders)
|
|
366
366
|
* .intersectAll(
|
|
367
|
-
* db.select({
|
|
368
|
-
* productId: vipCustomerOrders.productId,
|
|
369
|
-
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
|
367
|
+
* db.select({
|
|
368
|
+
* productId: vipCustomerOrders.productId,
|
|
369
|
+
* quantityOrdered: vipCustomerOrders.quantityOrdered
|
|
370
370
|
* })
|
|
371
371
|
* .from(vipCustomerOrders)
|
|
372
372
|
* );
|
|
373
373
|
* // or
|
|
374
374
|
* import { intersectAll } from 'drizzle-orm/pg-core'
|
|
375
|
-
*
|
|
375
|
+
*
|
|
376
376
|
* await intersectAll(
|
|
377
377
|
* db.select({
|
|
378
378
|
* productId: regularCustomerOrders.productId,
|
|
@@ -390,13 +390,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
390
390
|
intersectAll = this.createSetOperator("intersect", true);
|
|
391
391
|
/**
|
|
392
392
|
* Adds `except` set operator to the query.
|
|
393
|
-
*
|
|
393
|
+
*
|
|
394
394
|
* Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.
|
|
395
|
-
*
|
|
395
|
+
*
|
|
396
396
|
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except}
|
|
397
|
-
*
|
|
397
|
+
*
|
|
398
398
|
* @example
|
|
399
|
-
*
|
|
399
|
+
*
|
|
400
400
|
* ```ts
|
|
401
401
|
* // Select all courses offered in department A but not in department B
|
|
402
402
|
* await db.select({ courseName: depA.courseName })
|
|
@@ -406,7 +406,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
406
406
|
* );
|
|
407
407
|
* // or
|
|
408
408
|
* import { except } from 'drizzle-orm/pg-core'
|
|
409
|
-
*
|
|
409
|
+
*
|
|
410
410
|
* await except(
|
|
411
411
|
* db.select({ courseName: depA.courseName }).from(depA),
|
|
412
412
|
* db.select({ courseName: depB.courseName }).from(depB)
|
|
@@ -416,13 +416,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
416
416
|
except = this.createSetOperator("except", false);
|
|
417
417
|
/**
|
|
418
418
|
* Adds `except all` set operator to the query.
|
|
419
|
-
*
|
|
419
|
+
*
|
|
420
420
|
* Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.
|
|
421
|
-
*
|
|
421
|
+
*
|
|
422
422
|
* See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}
|
|
423
|
-
*
|
|
423
|
+
*
|
|
424
424
|
* @example
|
|
425
|
-
*
|
|
425
|
+
*
|
|
426
426
|
* ```ts
|
|
427
427
|
* // Select all products that are ordered by regular customers but not by VIP customers
|
|
428
428
|
* await db.select({
|
|
@@ -439,7 +439,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
439
439
|
* );
|
|
440
440
|
* // or
|
|
441
441
|
* import { exceptAll } from 'drizzle-orm/pg-core'
|
|
442
|
-
*
|
|
442
|
+
*
|
|
443
443
|
* await exceptAll(
|
|
444
444
|
* db.select({
|
|
445
445
|
* productId: regularCustomerOrders.productId,
|
|
@@ -460,35 +460,35 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
460
460
|
this.config.setOperators.push(...setOperators);
|
|
461
461
|
return this;
|
|
462
462
|
}
|
|
463
|
-
/**
|
|
463
|
+
/**
|
|
464
464
|
* Adds a `where` clause to the query.
|
|
465
|
-
*
|
|
465
|
+
*
|
|
466
466
|
* Calling this method will select only those rows that fulfill a specified condition.
|
|
467
|
-
*
|
|
467
|
+
*
|
|
468
468
|
* See docs: {@link https://orm.drizzle.team/docs/select#filtering}
|
|
469
|
-
*
|
|
469
|
+
*
|
|
470
470
|
* @param where the `where` clause.
|
|
471
|
-
*
|
|
471
|
+
*
|
|
472
472
|
* @example
|
|
473
473
|
* You can use conditional operators and `sql function` to filter the rows to be selected.
|
|
474
|
-
*
|
|
474
|
+
*
|
|
475
475
|
* ```ts
|
|
476
476
|
* // Select all cars with green color
|
|
477
477
|
* await db.select().from(cars).where(eq(cars.color, 'green'));
|
|
478
478
|
* // or
|
|
479
479
|
* await db.select().from(cars).where(sql`${cars.color} = 'green'`)
|
|
480
480
|
* ```
|
|
481
|
-
*
|
|
481
|
+
*
|
|
482
482
|
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
483
|
-
*
|
|
483
|
+
*
|
|
484
484
|
* ```ts
|
|
485
485
|
* // Select all BMW cars with a green color
|
|
486
486
|
* await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
487
|
-
*
|
|
487
|
+
*
|
|
488
488
|
* // Select all cars with the green or blue color
|
|
489
489
|
* await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
490
490
|
* ```
|
|
491
|
-
|
|
491
|
+
*/
|
|
492
492
|
where(where) {
|
|
493
493
|
if (typeof where === "function") {
|
|
494
494
|
where = where(
|
|
@@ -503,15 +503,15 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
503
503
|
}
|
|
504
504
|
/**
|
|
505
505
|
* Adds a `having` clause to the query.
|
|
506
|
-
*
|
|
506
|
+
*
|
|
507
507
|
* Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.
|
|
508
|
-
*
|
|
508
|
+
*
|
|
509
509
|
* See docs: {@link https://orm.drizzle.team/docs/select#aggregations}
|
|
510
|
-
*
|
|
510
|
+
*
|
|
511
511
|
* @param having the `having` clause.
|
|
512
|
-
*
|
|
512
|
+
*
|
|
513
513
|
* @example
|
|
514
|
-
*
|
|
514
|
+
*
|
|
515
515
|
* ```ts
|
|
516
516
|
* // Select all brands with more than one car
|
|
517
517
|
* await db.select({
|
|
@@ -575,13 +575,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
575
575
|
}
|
|
576
576
|
/**
|
|
577
577
|
* Adds a `limit` clause to the query.
|
|
578
|
-
*
|
|
578
|
+
*
|
|
579
579
|
* Calling this method will set the maximum number of rows that will be returned by this query.
|
|
580
580
|
*
|
|
581
581
|
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
|
582
|
-
*
|
|
582
|
+
*
|
|
583
583
|
* @param limit the `limit` clause.
|
|
584
|
-
*
|
|
584
|
+
*
|
|
585
585
|
* @example
|
|
586
586
|
*
|
|
587
587
|
* ```ts
|
|
@@ -599,13 +599,13 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
599
599
|
}
|
|
600
600
|
/**
|
|
601
601
|
* Adds an `offset` clause to the query.
|
|
602
|
-
*
|
|
602
|
+
*
|
|
603
603
|
* Calling this method will skip a number of rows when returning results from this query.
|
|
604
|
-
*
|
|
604
|
+
*
|
|
605
605
|
* See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}
|
|
606
|
-
*
|
|
606
|
+
*
|
|
607
607
|
* @param offset the `offset` clause.
|
|
608
|
-
*
|
|
608
|
+
*
|
|
609
609
|
* @example
|
|
610
610
|
*
|
|
611
611
|
* ```ts
|
|
@@ -623,11 +623,11 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
623
623
|
}
|
|
624
624
|
/**
|
|
625
625
|
* Adds a `for` clause to the query.
|
|
626
|
-
*
|
|
626
|
+
*
|
|
627
627
|
* Calling this method will specify a lock strength for this query that controls how strictly it acquires exclusive access to the rows being queried.
|
|
628
|
-
*
|
|
628
|
+
*
|
|
629
629
|
* See docs: {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE}
|
|
630
|
-
*
|
|
630
|
+
*
|
|
631
631
|
* @param strength the lock strength.
|
|
632
632
|
* @param config the lock configuration.
|
|
633
633
|
*/
|
|
@@ -662,6 +662,7 @@ class PgSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
662
662
|
}
|
|
663
663
|
class PgSelectBase extends PgSelectQueryBuilderBase {
|
|
664
664
|
static [entityKind] = "PgSelect";
|
|
665
|
+
/** @internal */
|
|
665
666
|
_prepare(name) {
|
|
666
667
|
const { session, config, dialect, joinsNotNullableMap } = this;
|
|
667
668
|
if (!session) {
|