pqb 0.4.3 → 0.4.4
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.esm.js +13 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/queryMethods/create.ts +14 -0
package/dist/index.esm.js
CHANGED
|
@@ -4256,6 +4256,7 @@ const insert = (self, {
|
|
|
4256
4256
|
columns,
|
|
4257
4257
|
values
|
|
4258
4258
|
}, returnType, ctx) => {
|
|
4259
|
+
var _a;
|
|
4259
4260
|
const q = self;
|
|
4260
4261
|
const returning = q.query.select;
|
|
4261
4262
|
delete q.query.and;
|
|
@@ -4288,6 +4289,15 @@ const insert = (self, {
|
|
|
4288
4289
|
})
|
|
4289
4290
|
);
|
|
4290
4291
|
}
|
|
4292
|
+
if (returnType === "oneOrThrow" || ((_a = q.query.fromQuery) == null ? void 0 : _a.query.returnType) === "oneOrThrow") {
|
|
4293
|
+
const { handleResult } = q.query;
|
|
4294
|
+
q.query.handleResult = async (q2, r) => {
|
|
4295
|
+
if (r.rowCount === 0) {
|
|
4296
|
+
throw new NotFoundError();
|
|
4297
|
+
}
|
|
4298
|
+
return await handleResult(q2, r);
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4291
4301
|
const appendRelationsKeys = Object.keys(ctx.appendRelations);
|
|
4292
4302
|
if (appendRelationsKeys.length) {
|
|
4293
4303
|
if (!(returning == null ? void 0 : returning.includes("*"))) {
|
|
@@ -4318,10 +4328,10 @@ const insert = (self, {
|
|
|
4318
4328
|
"afterQuery",
|
|
4319
4329
|
appendRelationsKeys.map((relationName) => {
|
|
4320
4330
|
return (q2, result) => {
|
|
4321
|
-
var
|
|
4331
|
+
var _a2, _b;
|
|
4322
4332
|
const all = resultOfTypeAll || result;
|
|
4323
|
-
return (_b = (
|
|
4324
|
-
|
|
4333
|
+
return (_b = (_a2 = ctx.relations[relationName]).nestedInsert) == null ? void 0 : _b.call(
|
|
4334
|
+
_a2,
|
|
4325
4335
|
q2,
|
|
4326
4336
|
ctx.appendRelations[relationName].map(([rowIndex, data]) => [
|
|
4327
4337
|
all[rowIndex],
|