@payloadcms/db-postgres 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +42 -15
- package/dist/find/chainMethods.d.ts +3 -2
- package/dist/find/chainMethods.d.ts.map +1 -1
- package/dist/find/chainMethods.js +1 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js +32 -54
- package/dist/queries/selectDistinct.d.ts +23 -0
- package/dist/queries/selectDistinct.d.ts.map +1 -0
- package/dist/queries/selectDistinct.js +49 -0
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +21 -46
- package/package.json +8 -4
package/dist/deleteOne.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;
|
1
|
+
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAajD,eAAO,MAAM,SAAS,EAAE,SAsDvB,CAAA"}
|
package/dist/deleteOne.js
CHANGED
@@ -8,40 +8,67 @@ Object.defineProperty(exports, "deleteOne", {
|
|
8
8
|
return deleteOne;
|
9
9
|
}
|
10
10
|
});
|
11
|
+
const _drizzleorm = require("drizzle-orm");
|
11
12
|
const _tosnakecase = /*#__PURE__*/ _interop_require_default(require("to-snake-case"));
|
12
13
|
const _buildFindManyArgs = require("./find/buildFindManyArgs");
|
13
14
|
const _buildQuery = /*#__PURE__*/ _interop_require_default(require("./queries/buildQuery"));
|
15
|
+
const _selectDistinct = require("./queries/selectDistinct");
|
14
16
|
const _read = require("./transform/read");
|
15
17
|
function _interop_require_default(obj) {
|
16
18
|
return obj && obj.__esModule ? obj : {
|
17
19
|
default: obj
|
18
20
|
};
|
19
21
|
}
|
20
|
-
const deleteOne = async function deleteOne({ collection, req = {}, where:
|
22
|
+
const deleteOne = async function deleteOne({ collection: collectionSlug, req = {}, where: whereArg }) {
|
21
23
|
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
22
|
-
const
|
23
|
-
const tableName = (0, _tosnakecase.default)(
|
24
|
-
|
24
|
+
const collection = this.payload.collections[collectionSlug].config;
|
25
|
+
const tableName = (0, _tosnakecase.default)(collectionSlug);
|
26
|
+
let docToDelete;
|
27
|
+
const { joinAliases, joins, selectFields, where } = await (0, _buildQuery.default)({
|
25
28
|
adapter: this,
|
26
|
-
fields:
|
29
|
+
fields: collection.fields,
|
30
|
+
locale: req.locale,
|
27
31
|
tableName,
|
28
|
-
where:
|
32
|
+
where: whereArg
|
29
33
|
});
|
30
|
-
const
|
34
|
+
const selectDistinctResult = await (0, _selectDistinct.selectDistinct)({
|
31
35
|
adapter: this,
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
chainedMethods: [
|
37
|
+
{
|
38
|
+
args: [
|
39
|
+
1
|
40
|
+
],
|
41
|
+
method: 'limit'
|
42
|
+
}
|
43
|
+
],
|
44
|
+
db,
|
45
|
+
joinAliases,
|
46
|
+
joins,
|
47
|
+
selectFields,
|
48
|
+
tableName,
|
49
|
+
where
|
35
50
|
});
|
36
|
-
|
37
|
-
|
51
|
+
if (selectDistinctResult?.[0]?.id) {
|
52
|
+
docToDelete = await db.query[tableName].findFirst({
|
53
|
+
where: (0, _drizzleorm.eq)(this.tables[tableName].id, selectDistinctResult[0].id)
|
54
|
+
});
|
55
|
+
} else {
|
56
|
+
const findManyArgs = (0, _buildFindManyArgs.buildFindManyArgs)({
|
57
|
+
adapter: this,
|
58
|
+
depth: 0,
|
59
|
+
fields: collection.fields,
|
60
|
+
tableName
|
61
|
+
});
|
62
|
+
findManyArgs.where = where;
|
63
|
+
docToDelete = await db.query[tableName].findFirst(findManyArgs);
|
64
|
+
}
|
38
65
|
const result = (0, _read.transform)({
|
39
66
|
config: this.payload.config,
|
40
67
|
data: docToDelete,
|
41
|
-
fields:
|
68
|
+
fields: collection.fields
|
42
69
|
});
|
43
|
-
await db.delete(this.tables[tableName]).where(
|
70
|
+
await db.delete(this.tables[tableName]).where((0, _drizzleorm.eq)(this.tables[tableName].id, docToDelete.id));
|
44
71
|
return result;
|
45
72
|
};
|
46
73
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
74
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9kZWxldGVPbmUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBEZWxldGVPbmUgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1wb3J0IHR5cGUgeyBQYXlsb2FkUmVxdWVzdCB9IGZyb20gJ3BheWxvYWQvdHlwZXMnXG5cbmltcG9ydCB7IGVxIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5pbXBvcnQgdG9TbmFrZUNhc2UgZnJvbSAndG8tc25ha2UtY2FzZSdcblxuaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuL3R5cGVzJ1xuXG5pbXBvcnQgeyBidWlsZEZpbmRNYW55QXJncyB9IGZyb20gJy4vZmluZC9idWlsZEZpbmRNYW55QXJncydcbmltcG9ydCBidWlsZFF1ZXJ5IGZyb20gJy4vcXVlcmllcy9idWlsZFF1ZXJ5J1xuaW1wb3J0IHsgc2VsZWN0RGlzdGluY3QgfSBmcm9tICcuL3F1ZXJpZXMvc2VsZWN0RGlzdGluY3QnXG5pbXBvcnQgeyB0cmFuc2Zvcm0gfSBmcm9tICcuL3RyYW5zZm9ybS9yZWFkJ1xuXG5leHBvcnQgY29uc3QgZGVsZXRlT25lOiBEZWxldGVPbmUgPSBhc3luYyBmdW5jdGlvbiBkZWxldGVPbmUoXG4gIHRoaXM6IFBvc3RncmVzQWRhcHRlcixcbiAgeyBjb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QUMyQixJQUFBQSxjQUFFLEVBQUMsSUFBSSxDQUFDQyxNQUFNLENBQUNuQixVQUFVLENBQUNlLEVBQUUsRUFBRWIsWUFBWWEsRUFBRTtJQUUxRixPQUFPUTtBQUNUIn0=
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { QueryPromise } from 'drizzle-orm';
|
1
2
|
export type ChainedMethods = {
|
2
3
|
args: unknown[];
|
3
4
|
method: string;
|
@@ -7,9 +8,9 @@ export type ChainedMethods = {
|
|
7
8
|
* @param methods
|
8
9
|
* @param query
|
9
10
|
*/
|
10
|
-
declare const chainMethods: ({ methods, query }: {
|
11
|
+
declare const chainMethods: <T>({ methods, query }: {
|
11
12
|
methods: any;
|
12
13
|
query: any;
|
13
|
-
}) =>
|
14
|
+
}) => QueryPromise<T>;
|
14
15
|
export { chainMethods };
|
15
16
|
//# sourceMappingURL=chainMethods.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"chainMethods.d.ts","sourceRoot":"","sources":["../../src/find/chainMethods.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,EAAE,CAAA;AAEH;;;;GAIG;AACH,QAAA,MAAM,YAAY;;;
|
1
|
+
{"version":3,"file":"chainMethods.d.ts","sourceRoot":"","sources":["../../src/find/chainMethods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,EAAE,CAAA;AAEH;;;;GAIG;AACH,QAAA,MAAM,YAAY;;;qBAIjB,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports, "chainMethods", {
|
|
18
18
|
}, query);
|
19
19
|
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QUFRRSxNQUFNLENBQUMsQ0FBQ0QsT0FBTyxFQUFFRSxJQUFJLEVBQUVDLE1BQU0sRUFBRTtRQUM1QyxPQUFPSCxLQUFLLENBQUNHLE9BQU8sSUFBSUQ7SUFDMUIsR0FBR0Y7QUFDTCJ9
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"findMany.d.ts","sourceRoot":"","sources":["../../src/find/findMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,eAAe,CAAA;AAItE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"findMany.d.ts","sourceRoot":"","sources":["../../src/find/findMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAA8B,MAAM,eAAe,CAAA;AAItE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAS/C,KAAK,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ,iHAYlB,IAAI;;;;;;;;;;;EAgKN,CAAA"}
|
package/dist/find/findMany.js
CHANGED
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "findMany", {
|
|
10
10
|
});
|
11
11
|
const _drizzleorm = require("drizzle-orm");
|
12
12
|
const _buildQuery = /*#__PURE__*/ _interop_require_default(require("../queries/buildQuery"));
|
13
|
+
const _selectDistinct = require("../queries/selectDistinct");
|
13
14
|
const _read = require("../transform/read");
|
14
15
|
const _buildFindManyArgs = require("./buildFindManyArgs");
|
15
16
|
const _chainMethods = require("./chainMethods");
|
@@ -27,7 +28,6 @@ const findMany = async function find({ adapter, fields, limit: limitArg, locale,
|
|
27
28
|
let hasPrevPage;
|
28
29
|
let hasNextPage;
|
29
30
|
let pagingCounter;
|
30
|
-
let selectDistinctResult;
|
31
31
|
const { joinAliases, joins, orderBy, selectFields, where } = await (0, _buildQuery.default)({
|
32
32
|
adapter,
|
33
33
|
fields,
|
@@ -53,52 +53,29 @@ const findMany = async function find({ adapter, fields, limit: limitArg, locale,
|
|
53
53
|
fields,
|
54
54
|
tableName
|
55
55
|
});
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
adapter.tables[joinTable],
|
80
|
-
condition
|
81
|
-
],
|
82
|
-
method: 'leftJoin'
|
83
|
-
});
|
84
|
-
}
|
85
|
-
});
|
86
|
-
selectDistinctMethods.push({
|
87
|
-
args: [
|
88
|
-
skip || (page - 1) * limit
|
89
|
-
],
|
90
|
-
method: 'offset'
|
91
|
-
});
|
92
|
-
selectDistinctMethods.push({
|
93
|
-
args: [
|
94
|
-
limit === 0 ? undefined : limit
|
95
|
-
],
|
96
|
-
method: 'limit'
|
97
|
-
});
|
98
|
-
selectDistinctResult = await (0, _chainMethods.chainMethods)({
|
99
|
-
methods: selectDistinctMethods,
|
100
|
-
query: db.selectDistinct(selectFields).from(table)
|
101
|
-
});
|
56
|
+
selectDistinctMethods.push({
|
57
|
+
args: [
|
58
|
+
skip || (page - 1) * limit
|
59
|
+
],
|
60
|
+
method: 'offset'
|
61
|
+
});
|
62
|
+
selectDistinctMethods.push({
|
63
|
+
args: [
|
64
|
+
limit === 0 ? undefined : limit
|
65
|
+
],
|
66
|
+
method: 'limit'
|
67
|
+
});
|
68
|
+
const selectDistinctResult = await (0, _selectDistinct.selectDistinct)({
|
69
|
+
adapter,
|
70
|
+
chainedMethods: selectDistinctMethods,
|
71
|
+
db,
|
72
|
+
joinAliases,
|
73
|
+
joins,
|
74
|
+
selectFields,
|
75
|
+
tableName,
|
76
|
+
where
|
77
|
+
});
|
78
|
+
if (selectDistinctResult) {
|
102
79
|
if (selectDistinctResult.length === 0) {
|
103
80
|
return {
|
104
81
|
docs: [],
|
@@ -112,13 +89,14 @@ const findMany = async function find({ adapter, fields, limit: limitArg, locale,
|
|
112
89
|
totalDocs: 0,
|
113
90
|
totalPages: 0
|
114
91
|
};
|
92
|
+
} else {
|
93
|
+
// set the id in an object for sorting later
|
94
|
+
selectDistinctResult.forEach(({ id }, i)=>{
|
95
|
+
orderedIDMap[id] = i;
|
96
|
+
});
|
97
|
+
orderedIDs = Object.keys(orderedIDMap);
|
98
|
+
findManyArgs.where = (0, _drizzleorm.inArray)(adapter.tables[tableName].id, orderedIDs);
|
115
99
|
}
|
116
|
-
// set the id in an object for sorting later
|
117
|
-
selectDistinctResult.forEach(({ id }, i)=>{
|
118
|
-
orderedIDMap[id] = i;
|
119
|
-
});
|
120
|
-
orderedIDs = Object.keys(orderedIDMap);
|
121
|
-
findManyArgs.where = (0, _drizzleorm.inArray)(adapter.tables[tableName].id, orderedIDs);
|
122
100
|
} else {
|
123
101
|
findManyArgs.limit = limitArg === 0 ? undefined : limitArg;
|
124
102
|
const offset = skip || (page - 1) * limitArg;
|
@@ -197,4 +175,4 @@ const findMany = async function find({ adapter, fields, limit: limitArg, locale,
|
|
197
175
|
};
|
198
176
|
};
|
199
177
|
|
200
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9maW5kL2ZpbmRNYW55LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgRmluZEFyZ3MgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuaW1w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CLEVBQUUsQ0FBQyxHQUFHcEIsWUFBWSxDQUFDNkMsRUFBRXpCLEVBQUUsQ0FBQztJQUNoRTtJQUVBLElBQUkzQyxlQUFlLFNBQVMsQ0FBQ2EsV0FBVztRQUN0Q0EsWUFBWXFELFFBQVE1QixNQUFNO1FBQzFCeEIsYUFBYTtRQUNiRyxnQkFBZ0I7UUFDaEJGLGNBQWM7UUFDZEMsY0FBYztJQUNoQjtJQUVBLE1BQU11QixPQUFPMkIsUUFBUUcsR0FBRyxDQUFDLENBQUNDO1FBQ3hCLE9BQU9DLElBQUFBLGVBQVMsRUFBQztZQUNmQyxRQUFROUUsUUFBUStFLE9BQU8sQ0FBQ0QsTUFBTTtZQUM5QkY7WUFDQTNFO1FBQ0Y7SUFDRjtJQUVBLE9BQU87UUFDTDRDO1FBQ0F2QjtRQUNBRDtRQUNBbkI7UUFDQTRDLFVBQVV4QixjQUFjakIsT0FBTyxJQUFJO1FBQ25DQTtRQUNBa0I7UUFDQXdCLFVBQVUxQixjQUFjaEIsT0FBTyxJQUFJO1FBQ25DYztRQUNBQztJQUNGO0FBQ0YifQ==
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { QueryPromise, SQL } from 'drizzle-orm';
|
2
|
+
import type { ChainedMethods } from '../find/chainMethods';
|
3
|
+
import type { DrizzleDB, PostgresAdapter } from '../types';
|
4
|
+
import type { BuildQueryJoinAliases, BuildQueryJoins } from './buildQuery';
|
5
|
+
import { type GenericColumn } from '../types';
|
6
|
+
type Args = {
|
7
|
+
adapter: PostgresAdapter;
|
8
|
+
chainedMethods?: ChainedMethods;
|
9
|
+
db: DrizzleDB;
|
10
|
+
joinAliases: BuildQueryJoinAliases;
|
11
|
+
joins: BuildQueryJoins;
|
12
|
+
selectFields: Record<string, GenericColumn>;
|
13
|
+
tableName: string;
|
14
|
+
where: SQL;
|
15
|
+
};
|
16
|
+
/**
|
17
|
+
* Selects distinct records from a table only if there are joins that need to be used, otherwise return null
|
18
|
+
*/
|
19
|
+
export declare const selectDistinct: ({ adapter, chainedMethods, db, joinAliases, joins, selectFields, tableName, where, }: Args) => QueryPromise<Record<string, GenericColumn> & {
|
20
|
+
id: number | string;
|
21
|
+
}[]>;
|
22
|
+
export {};
|
23
|
+
//# sourceMappingURL=selectDistinct.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"selectDistinct.d.ts","sourceRoot":"","sources":["../../src/queries/selectDistinct.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1D,OAAO,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG1E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAA;AAE7C,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,eAAe,CAAA;IACxB,cAAc,CAAC,EAAE,cAAc,CAAA;IAC/B,EAAE,EAAE,SAAS,CAAA;IACb,WAAW,EAAE,qBAAqB,CAAA;IAClC,KAAK,EAAE,eAAe,CAAA;IACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,yFASxB,IAAI,KAAG,aAAa,OAAO,MAAM,EAAE,aAAa,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAAE,CA2B/E,CAAA"}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "selectDistinct", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return selectDistinct;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _chainMethods = require("../find/chainMethods");
|
12
|
+
const selectDistinct = ({ adapter, chainedMethods = [], db, joinAliases, joins, selectFields, tableName, where })=>{
|
13
|
+
if (Object.keys(joins).length > 0 || joinAliases.length > 0) {
|
14
|
+
if (where) {
|
15
|
+
chainedMethods.push({
|
16
|
+
args: [
|
17
|
+
where
|
18
|
+
],
|
19
|
+
method: 'where'
|
20
|
+
});
|
21
|
+
}
|
22
|
+
joinAliases.forEach(({ condition, table })=>{
|
23
|
+
chainedMethods.push({
|
24
|
+
args: [
|
25
|
+
table,
|
26
|
+
condition
|
27
|
+
],
|
28
|
+
method: 'leftJoin'
|
29
|
+
});
|
30
|
+
});
|
31
|
+
Object.entries(joins).forEach(([joinTable, condition])=>{
|
32
|
+
if (joinTable) {
|
33
|
+
chainedMethods.push({
|
34
|
+
args: [
|
35
|
+
adapter.tables[joinTable],
|
36
|
+
condition
|
37
|
+
],
|
38
|
+
method: 'leftJoin'
|
39
|
+
});
|
40
|
+
}
|
41
|
+
});
|
42
|
+
return (0, _chainMethods.chainMethods)({
|
43
|
+
methods: chainedMethods,
|
44
|
+
query: db.selectDistinct(selectFields).from(adapter.tables[tableName])
|
45
|
+
});
|
46
|
+
}
|
47
|
+
};
|
48
|
+
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9xdWVyaWVzL3NlbGVjdERpc3RpbmN0LnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgUXVlcnlQcm9taXNlLCBTUUwgfSBmcm9tICdkcml6emxlLW9ybSdcblxuaW1wb3J0IHR5cGUgeyBDaGFpbmVkTWV0aG9kcyB9IGZyb20gJy4uL2ZpbmQvY2hhaW5NZXRob2RzJ1xuaW1wb3J0IHR5cGUgeyBEcml6emxlREIsIFBv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FBQ0QsVUFBVTt3QkFBRUg7cUJBQVU7b0JBQzVDRixRQUFRO2dCQUNWO1lBQ0Y7UUFDRjtRQUVBLE9BQU9PLElBQUFBLDBCQUFZLEVBQUM7WUFDbEJDLFNBQVNwQjtZQUNUcUIsT0FBT3BCLEdBQUdILGNBQWMsQ0FBQ00sY0FBY2tCLElBQUksQ0FBQ3ZCLFFBQVFtQixNQUFNLENBQUNiLFVBQVU7UUFDdkU7SUFDRjtBQUNGIn0=
|
package/dist/update.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAUjD,eAAO,MAAM,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAUjD,eAAO,MAAM,SAAS,EAAE,SA6CvB,CAAA"}
|
package/dist/update.js
CHANGED
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "updateOne", {
|
|
9
9
|
}
|
10
10
|
});
|
11
11
|
const _tosnakecase = /*#__PURE__*/ _interop_require_default(require("to-snake-case"));
|
12
|
-
const _chainMethods = require("./find/chainMethods");
|
13
12
|
const _buildQuery = /*#__PURE__*/ _interop_require_default(require("./queries/buildQuery"));
|
13
|
+
const _selectDistinct = require("./queries/selectDistinct");
|
14
14
|
const _upsertRow = require("./upsertRow");
|
15
15
|
function _interop_require_default(obj) {
|
16
16
|
return obj && obj.__esModule ? obj : {
|
@@ -26,6 +26,7 @@ const updateOne = async function updateOne({ id, collection: collectionSlug, dat
|
|
26
26
|
equals: id
|
27
27
|
}
|
28
28
|
};
|
29
|
+
let idToUpdate = id;
|
29
30
|
const { joinAliases, joins, selectFields, where } = await (0, _buildQuery.default)({
|
30
31
|
adapter: this,
|
31
32
|
fields: collection.fields,
|
@@ -33,51 +34,25 @@ const updateOne = async function updateOne({ id, collection: collectionSlug, dat
|
|
33
34
|
tableName,
|
34
35
|
where: whereToUse
|
35
36
|
});
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if (where) {
|
41
|
-
selectDistinctMethods.push({
|
42
|
-
args: [
|
43
|
-
where
|
44
|
-
],
|
45
|
-
method: 'where'
|
46
|
-
});
|
47
|
-
}
|
48
|
-
joinAliases.forEach(({ condition, table })=>{
|
49
|
-
selectDistinctMethods.push({
|
37
|
+
const selectDistinctResult = await (0, _selectDistinct.selectDistinct)({
|
38
|
+
adapter: this,
|
39
|
+
chainedMethods: [
|
40
|
+
{
|
50
41
|
args: [
|
51
|
-
|
52
|
-
condition
|
42
|
+
1
|
53
43
|
],
|
54
|
-
method: '
|
55
|
-
});
|
56
|
-
});
|
57
|
-
Object.entries(joins).forEach(([joinTable, condition])=>{
|
58
|
-
if (joinTable) {
|
59
|
-
selectDistinctMethods.push({
|
60
|
-
args: [
|
61
|
-
this.tables[joinTable],
|
62
|
-
condition
|
63
|
-
],
|
64
|
-
method: 'leftJoin'
|
65
|
-
});
|
44
|
+
method: 'limit'
|
66
45
|
}
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
});
|
78
|
-
if (selectDistinctResult?.[0]?.id) {
|
79
|
-
idToUpdate = selectDistinctResult?.[0]?.id;
|
80
|
-
}
|
46
|
+
],
|
47
|
+
db,
|
48
|
+
joinAliases,
|
49
|
+
joins,
|
50
|
+
selectFields,
|
51
|
+
tableName,
|
52
|
+
where
|
53
|
+
});
|
54
|
+
if (selectDistinctResult?.[0]?.id) {
|
55
|
+
idToUpdate = selectDistinctResult?.[0]?.id;
|
81
56
|
}
|
82
57
|
const result = await (0, _upsertRow.upsertRow)({
|
83
58
|
id: idToUpdate,
|
@@ -86,10 +61,10 @@ const updateOne = async function updateOne({ id, collection: collectionSlug, dat
|
|
86
61
|
db,
|
87
62
|
fields: collection.fields,
|
88
63
|
operation: 'update',
|
89
|
-
|
90
|
-
|
64
|
+
req,
|
65
|
+
tableName: (0, _tosnakecase.default)(collectionSlug)
|
91
66
|
});
|
92
67
|
return result;
|
93
68
|
};
|
94
69
|
|
95
|
-
//# sourceMappingURL=data:application/json;base64,
|
70
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91cGRhdGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHR5cGUgeyBVcGRhdGVPbmUgfSBmcm9tICdwYXlsb2FkL2RhdGFiYXNlJ1xuXG5pbXBvcnQgdG9TbmFrZUNhc2UgZnJvbSAndG8tc25ha2UtY2FzZSdcblxuaW1wb3J0IHR5cGUgeyBQb3N0Z3Jlc0FkYXB0ZXIgfSBmcm9tICcuL3R5cGVzJ1xuXG5pbXBvcnQgYnVpbGRRdWVyeSBmcm9tICcuL3F1ZXJpZXMvYnVpbGRRdWVyeSdcbmltcG9ydCB7IHNlbGVjdERpc3RpbmN0IH0gZnJvbSAnLi9xdWVyaWVzL3NlbGVjdERpc3RpbmN0J1xuaW1wb3J0IHsgdXBzZXJ0Um93IH0gZnJvbSAnLi91cHNlcnRSb3cnXG5cbmV4cG9ydCBjb25zdCB1cGRhdGVPbmU6IFVwZGF0ZU9uZSA9IGFzeW5jIGZ1bmN0aW9uIHVwZGF0ZU9uZShcbiAgdGhpczogUG9zdGdyZXNBZGFwdGVyLFxuICB7IGlkLCBjb2xsZWN0aW9uOiBjb2xsZWN0aW9uU2x1ZywgZGF0YSwgZHJhZnQsIGxvY2FsZSwgcmVxLCB3aGVyZTogd2hlcmVBcmcgfSxcbikge1xuICBjb25zdCBkYiA9IHRoaXMuc2Vzc2lvbnNbcmVxLnRyYW5zYWN0aW9uSURdPy5kYiB8fCB0aGlzLmRyaXp6bGVcbiA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csRUFBQ2Y7SUFDekI7SUFFQSxPQUFPOEI7QUFDVCJ9
|
package/package.json
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-postgres",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.1",
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
5
|
-
"repository":
|
5
|
+
"repository": {
|
6
|
+
"type": "git",
|
7
|
+
"url": "https://github.com/payloadcms/payload.git",
|
8
|
+
"directory": "packages/db-postgres"
|
9
|
+
},
|
6
10
|
"license": "MIT",
|
7
11
|
"homepage": "https://payloadcms.com",
|
8
12
|
"author": {
|
@@ -25,8 +29,8 @@
|
|
25
29
|
"devDependencies": {
|
26
30
|
"@types/pg": "8.10.2",
|
27
31
|
"@types/to-snake-case": "1.0.0",
|
28
|
-
"
|
29
|
-
"
|
32
|
+
"@payloadcms/eslint-config": "1.1.1",
|
33
|
+
"payload": "2.12.0"
|
30
34
|
},
|
31
35
|
"peerDependencies": {
|
32
36
|
"payload": "^2.0.0"
|