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/package.json
CHANGED
|
@@ -25,6 +25,7 @@ import { EmptyObject, SetOptional } from '../utils';
|
|
|
25
25
|
import { InsertQueryData, OnConflictItem, OnConflictMergeUpdate } from '../sql';
|
|
26
26
|
import { WhereArg } from './where';
|
|
27
27
|
import { parseResult, queryMethodByReturnType } from './then';
|
|
28
|
+
import { NotFoundError } from '../errors';
|
|
28
29
|
|
|
29
30
|
export type CreateData<
|
|
30
31
|
T extends Query,
|
|
@@ -351,6 +352,19 @@ const insert = (
|
|
|
351
352
|
);
|
|
352
353
|
}
|
|
353
354
|
|
|
355
|
+
if (
|
|
356
|
+
returnType === 'oneOrThrow' ||
|
|
357
|
+
q.query.fromQuery?.query.returnType === 'oneOrThrow'
|
|
358
|
+
) {
|
|
359
|
+
const { handleResult } = q.query;
|
|
360
|
+
q.query.handleResult = async (q, r) => {
|
|
361
|
+
if (r.rowCount === 0) {
|
|
362
|
+
throw new NotFoundError();
|
|
363
|
+
}
|
|
364
|
+
return await handleResult(q, r);
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
354
368
|
const appendRelationsKeys = Object.keys(ctx.appendRelations);
|
|
355
369
|
if (appendRelationsKeys.length) {
|
|
356
370
|
if (!returning?.includes('*')) {
|