pqb 0.69.0 → 0.70.0
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/dist/index.d.ts +226 -200
- package/dist/index.js +60 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +60 -18
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +203 -178
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8052,22 +8052,6 @@ const numericResultColumn = (q, arg) => {
|
|
|
8052
8052
|
return (typeof arg === "string" ? _getSelectableColumn(q, arg) : arg.result.value) instanceof NumberBaseColumn ? floatNullable : stringAsNumberNullable;
|
|
8053
8053
|
};
|
|
8054
8054
|
var AggregateMethods = class {
|
|
8055
|
-
/**
|
|
8056
|
-
* Use `exists()` to check if there is at least one record-matching condition.
|
|
8057
|
-
*
|
|
8058
|
-
* It will discard previous `select` statements if any. Returns a boolean.
|
|
8059
|
-
*
|
|
8060
|
-
* ```ts
|
|
8061
|
-
* const exists: boolean = await db.table.where(...conditions).exists();
|
|
8062
|
-
* ```
|
|
8063
|
-
*/
|
|
8064
|
-
exists() {
|
|
8065
|
-
const q = _queryGetOptional(_clone(this), new RawSql("true"));
|
|
8066
|
-
q.q.notFoundDefault = false;
|
|
8067
|
-
q.q.coalesceValue = new RawSql("false");
|
|
8068
|
-
q.q.getColumn = BooleanColumn.instanceSkipValueToArray;
|
|
8069
|
-
return q;
|
|
8070
|
-
}
|
|
8071
8055
|
/**
|
|
8072
8056
|
* Count records with the `count` function:
|
|
8073
8057
|
*
|
|
@@ -13288,6 +13272,39 @@ var QueryWindow = class {
|
|
|
13288
13272
|
return pushQueryValueImmutable(_clone(this), "window", arg);
|
|
13289
13273
|
}
|
|
13290
13274
|
};
|
|
13275
|
+
const _exists = (query, value) => {
|
|
13276
|
+
const q = _queryGetOptional(_clone(query), new RawSql(String(value)));
|
|
13277
|
+
q.q.notFoundDefault = !value;
|
|
13278
|
+
q.q.coalesceValue = new RawSql(String(!value));
|
|
13279
|
+
q.q.getColumn = BooleanColumn.instanceSkipValueToArray;
|
|
13280
|
+
return q;
|
|
13281
|
+
};
|
|
13282
|
+
var QueryExistsMethods = class {
|
|
13283
|
+
/**
|
|
13284
|
+
* Use `exists()` to check if there is at least one record-matching condition.
|
|
13285
|
+
*
|
|
13286
|
+
* It will discard previous `select` statements if any. Returns a boolean.
|
|
13287
|
+
*
|
|
13288
|
+
* ```ts
|
|
13289
|
+
* const exists: boolean = await db.table.where(...conditions).exists();
|
|
13290
|
+
* ```
|
|
13291
|
+
*/
|
|
13292
|
+
exists() {
|
|
13293
|
+
return _exists(this, true);
|
|
13294
|
+
}
|
|
13295
|
+
/**
|
|
13296
|
+
* Use `notExists()` to check if there are no matching records.
|
|
13297
|
+
*
|
|
13298
|
+
* It will discard previous `select` statements if any. Returns a boolean.
|
|
13299
|
+
*
|
|
13300
|
+
* ```ts
|
|
13301
|
+
* const exists: boolean = await db.table.where(...conditions).notExists();
|
|
13302
|
+
* ```
|
|
13303
|
+
*/
|
|
13304
|
+
notExists() {
|
|
13305
|
+
return _exists(this, false);
|
|
13306
|
+
}
|
|
13307
|
+
};
|
|
13291
13308
|
var QueryMethods = class {
|
|
13292
13309
|
/**
|
|
13293
13310
|
* `.all` is a default behavior, that returns an array of objects:
|
|
@@ -13361,6 +13378,30 @@ var QueryMethods = class {
|
|
|
13361
13378
|
return _queryExec(_clone(this));
|
|
13362
13379
|
}
|
|
13363
13380
|
/**
|
|
13381
|
+
* For relation selects, `require` changes LEFT JOIN LATERAL to JOIN LATERAL.
|
|
13382
|
+
*
|
|
13383
|
+
* ```ts
|
|
13384
|
+
* // only the records that have `related` will be loaded:
|
|
13385
|
+
* await db.table.select({ related: (q) => q.related.required() });
|
|
13386
|
+
* ```
|
|
13387
|
+
*/
|
|
13388
|
+
require() {
|
|
13389
|
+
const query = _clone(this);
|
|
13390
|
+
switch (query.q.returnType) {
|
|
13391
|
+
case void 0:
|
|
13392
|
+
case "all":
|
|
13393
|
+
case "valueOrThrow":
|
|
13394
|
+
case "pluck":
|
|
13395
|
+
case "void": break;
|
|
13396
|
+
case "value":
|
|
13397
|
+
query.q.returnType = "valueOrThrow";
|
|
13398
|
+
break;
|
|
13399
|
+
default: query.q.returnType = "oneOrThrow";
|
|
13400
|
+
}
|
|
13401
|
+
query.q.innerJoinLateral = true;
|
|
13402
|
+
return query;
|
|
13403
|
+
}
|
|
13404
|
+
/**
|
|
13364
13405
|
* Call `toSQL` on a query to get an object with a `text` SQL string and a `values` array of binding values:
|
|
13365
13406
|
*
|
|
13366
13407
|
* ```ts
|
|
@@ -13564,7 +13605,7 @@ var QueryMethods = class {
|
|
|
13564
13605
|
* // all the following queries will resolve into empty arrays
|
|
13565
13606
|
*
|
|
13566
13607
|
* await db.user.select({
|
|
13567
|
-
* pets: (q) => q.pets.
|
|
13608
|
+
* pets: (q) => q.pets.require().none(),
|
|
13568
13609
|
* });
|
|
13569
13610
|
*
|
|
13570
13611
|
* await db.user.join((q) => q.pets.none());
|
|
@@ -13814,7 +13855,8 @@ applyMixins(QueryMethods, [
|
|
|
13814
13855
|
SoftDeleteMethods,
|
|
13815
13856
|
QueryExpressions,
|
|
13816
13857
|
QueryWrap,
|
|
13817
|
-
QueryWindow
|
|
13858
|
+
QueryWindow,
|
|
13859
|
+
QueryExistsMethods
|
|
13818
13860
|
]);
|
|
13819
13861
|
const performQuery = async (q, args, method) => {
|
|
13820
13862
|
const trx = q.internal.asyncStorage.getStore();
|