@payloadcms/db-mongodb 3.2.2-canary.d2399ed → 3.2.3-canary.2d2e7d5
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/count.d.ts.map +1 -1
- package/dist/count.js +21 -19
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +21 -19
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +21 -19
- package/dist/countVersions.js.map +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +22 -22
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +19 -21
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +30 -35
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +30 -35
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +6 -6
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +13 -17
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +6 -6
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +74 -41
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +18 -19
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +62 -33
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +19 -32
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +62 -34
- package/dist/findVersions.js.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +16 -20
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -1
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js +2 -2
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +1 -3
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +1 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +0 -2
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +6 -2
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts +1 -3
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +10 -14
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +7 -1
- package/dist/queries/buildSortParam.d.ts.map +1 -1
- package/dist/queries/buildSortParam.js +2 -2
- package/dist/queries/buildSortParam.js.map +1 -1
- package/dist/queries/getLocalizedSortProperty.js +2 -2
- package/dist/queries/getLocalizedSortProperty.js.map +1 -1
- package/dist/queries/parseParams.d.ts +1 -3
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +1 -2
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +0 -16
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +65 -41
- package/dist/queryDrafts.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +23 -25
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +27 -28
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +24 -28
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +26 -28
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts +4 -4
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +28 -7
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.js +1 -18
- package/dist/utilities/buildProjectionFromSelect.js.map +1 -1
- package/dist/utilities/sanitizeInternalFields.d.ts +2 -0
- package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -0
- package/dist/utilities/sanitizeInternalFields.js +20 -0
- package/dist/utilities/sanitizeInternalFields.js.map +1 -0
- package/dist/utilities/sanitizeRelationshipIDs.d.ts +9 -0
- package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +1 -0
- package/dist/utilities/sanitizeRelationshipIDs.js +125 -0
- package/dist/utilities/sanitizeRelationshipIDs.js.map +1 -0
- package/dist/utilities/{transform.spec.js → sanitizeRelationshipIDs.spec.js} +7 -23
- package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +1 -0
- package/dist/{getSession.d.ts → withSession.d.ts} +4 -2
- package/dist/withSession.d.ts.map +1 -0
- package/dist/{getSession.js → withSession.js} +5 -3
- package/dist/withSession.js.map +1 -0
- package/package.json +3 -3
- package/dist/getSession.d.ts.map +0 -1
- package/dist/getSession.js.map +0 -1
- package/dist/utilities/findMany.d.ts +0 -20
- package/dist/utilities/findMany.d.ts.map +0 -1
- package/dist/utilities/findMany.js +0 -84
- package/dist/utilities/findMany.js.map +0 -1
- package/dist/utilities/getHasNearConstraint.d.ts +0 -3
- package/dist/utilities/getHasNearConstraint.d.ts.map +0 -1
- package/dist/utilities/getHasNearConstraint.js +0 -26
- package/dist/utilities/getHasNearConstraint.js.map +0 -1
- package/dist/utilities/transform.d.ts +0 -17
- package/dist/utilities/transform.d.ts.map +0 -1
- package/dist/utilities/transform.js +0 -250
- package/dist/utilities/transform.js.map +0 -1
- package/dist/utilities/transform.spec.js.map +0 -1
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import { buildVersionGlobalFields } from 'payload';
|
|
2
|
-
import { getSession } from './getSession.js';
|
|
1
|
+
import { buildVersionGlobalFields, flattenWhereToOperators } from 'payload';
|
|
3
2
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
4
3
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { transform } from './utilities/transform.js';
|
|
4
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
5
|
+
import { withSession } from './withSession.js';
|
|
8
6
|
export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, select, skip, sort: sortArg, where }) {
|
|
9
7
|
const Model = this.versions[global];
|
|
10
8
|
const versionFields = buildVersionGlobalFields(this.payload.config, this.payload.globals.config.find(({ slug })=>slug === global), true);
|
|
11
|
-
const
|
|
9
|
+
const options = {
|
|
10
|
+
...await withSession(this, req),
|
|
11
|
+
limit,
|
|
12
|
+
skip
|
|
13
|
+
};
|
|
14
|
+
let hasNearConstraint = false;
|
|
15
|
+
if (where) {
|
|
16
|
+
const constraints = flattenWhereToOperators(where);
|
|
17
|
+
hasNearConstraint = constraints.some((prop)=>Object.keys(prop).some((key)=>key === 'near'));
|
|
18
|
+
}
|
|
12
19
|
let sort;
|
|
13
20
|
if (!hasNearConstraint) {
|
|
14
21
|
sort = buildSortParam({
|
|
@@ -19,46 +26,68 @@ export const findGlobalVersions = async function findGlobalVersions({ global, li
|
|
|
19
26
|
timestamps: true
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
|
-
const session = await getSession(this, req);
|
|
23
29
|
const query = await Model.buildQuery({
|
|
24
30
|
globalSlug: global,
|
|
25
31
|
locale,
|
|
26
32
|
payload: this.payload,
|
|
27
|
-
session,
|
|
28
33
|
where
|
|
29
34
|
});
|
|
30
35
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
31
36
|
const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
select
|
|
36
|
-
});
|
|
37
|
-
const collation = this.collation ? {
|
|
38
|
-
locale: locale && locale !== 'all' && locale !== '*' ? locale : 'en',
|
|
39
|
-
...this.collation
|
|
40
|
-
} : undefined;
|
|
41
|
-
const result = await findMany({
|
|
42
|
-
adapter: this,
|
|
43
|
-
collation,
|
|
44
|
-
collection: Model.collection,
|
|
37
|
+
const paginationOptions = {
|
|
38
|
+
lean: true,
|
|
39
|
+
leanWithId: true,
|
|
45
40
|
limit,
|
|
41
|
+
options,
|
|
46
42
|
page,
|
|
47
43
|
pagination,
|
|
48
|
-
projection
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
projection: buildProjectionFromSelect({
|
|
45
|
+
adapter: this,
|
|
46
|
+
fields: versionFields,
|
|
47
|
+
select
|
|
48
|
+
}),
|
|
52
49
|
sort,
|
|
53
50
|
useEstimatedCount
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
};
|
|
52
|
+
if (this.collation) {
|
|
53
|
+
const defaultLocale = 'en';
|
|
54
|
+
paginationOptions.collation = {
|
|
55
|
+
locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,
|
|
56
|
+
...this.collation
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {
|
|
60
|
+
// Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding
|
|
61
|
+
// a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,
|
|
62
|
+
// which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses
|
|
63
|
+
// the correct indexed field
|
|
64
|
+
paginationOptions.useCustomCountFn = ()=>{
|
|
65
|
+
return Promise.resolve(Model.countDocuments(query, {
|
|
66
|
+
...options,
|
|
67
|
+
hint: {
|
|
68
|
+
_id: 1
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (limit >= 0) {
|
|
74
|
+
paginationOptions.limit = limit;
|
|
75
|
+
// limit must also be set here, it's ignored when pagination is false
|
|
76
|
+
paginationOptions.options.limit = limit;
|
|
77
|
+
// Disable pagination if limit is 0
|
|
78
|
+
if (limit === 0) {
|
|
79
|
+
paginationOptions.pagination = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const result = await Model.paginate(query, paginationOptions);
|
|
83
|
+
const docs = JSON.parse(JSON.stringify(result.docs));
|
|
84
|
+
return {
|
|
85
|
+
...result,
|
|
86
|
+
docs: docs.map((doc)=>{
|
|
87
|
+
doc.id = doc._id;
|
|
88
|
+
return sanitizeInternalFields(doc);
|
|
89
|
+
})
|
|
90
|
+
};
|
|
62
91
|
};
|
|
63
92
|
|
|
64
93
|
//# sourceMappingURL=findGlobalVersions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { FindGlobalVersions, PayloadRequest } from 'payload'\n\nimport { buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n select,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const Model = this.versions[global]\n const versionFields = buildVersionGlobalFields(\n this.payload.config,\n this.payload.globals.config.find(({ slug }) => slug === global),\n true,\n )\n const options = {\n ...(await withSession(this, req)),\n limit,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: versionFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await Model.buildQuery({\n globalSlug: global,\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({ adapter: this, fields: versionFields, select }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n ...options,\n hint: { _id: 1 },\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n paginationOptions.options.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildSortParam","buildProjectionFromSelect","sanitizeInternalFields","withSession","findGlobalVersions","global","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","Model","versions","versionFields","payload","config","globals","find","slug","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","buildQuery","globalSlug","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","adapter","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","docs","JSON","parse","stringify","map","doc","id"],"mappings":"AAGA,SAASA,wBAAwB,EAAEC,uBAAuB,QAAQ,UAAS;AAI3E,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAM,EACNC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,QAAQ,IAAI,CAACC,QAAQ,CAACZ,OAAO;IACnC,MAAMa,gBAAgBpB,yBACpB,IAAI,CAACqB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACE,OAAO,CAACD,MAAM,CAAC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;QAC5BP,kBAAkBQ,gBAAgB,GAAG;YACnC,OAAOC,QAAQC,OAAO,CACpBjC,MAAMkC,cAAc,CAAChB,OAAO;gBAC1B,GAAGV,OAAO;gBACV2B,MAAM;oBAAEC,KAAK;gBAAE;YACjB;QAEJ;IACF;IAEA,IAAI9C,SAAS,GAAG;QACdiC,kBAAkBjC,KAAK,GAAGA;QAC1B,qEAAqE;QACrEiC,kBAAkBf,OAAO,CAAClB,KAAK,GAAGA;QAElC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACfiC,kBAAkB9B,UAAU,GAAG;QACjC;IACF;IAEA,MAAM4C,SAAS,MAAMrC,MAAMsC,QAAQ,CAACpB,OAAOK;IAC3C,MAAMgB,OAAOC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL,OAAOE,IAAI;IAElD,OAAO;QACL,GAAGF,MAAM;QACTE,MAAMA,KAAKI,GAAG,CAAC,CAACC;YACdA,IAAIC,EAAE,GAAGD,IAAIR,GAAG;YAChB,OAAOlD,uBAAuB0D;QAChC;IACF;AACF,EAAC"}
|
package/dist/findOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,OAAO,EAAkB,MAAM,SAAS,CAAA;AAShE,eAAO,MAAM,OAAO,EAAE,OAqDrB,CAAA"}
|
package/dist/findOne.js
CHANGED
|
@@ -1,62 +1,49 @@
|
|
|
1
|
-
import { getSession } from './getSession.js';
|
|
2
1
|
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
|
3
2
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
4
|
-
import {
|
|
3
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
4
|
+
import { withSession } from './withSession.js';
|
|
5
5
|
export const findOne = async function findOne({ collection, joins, locale, req = {}, select, where }) {
|
|
6
6
|
const Model = this.collections[collection];
|
|
7
7
|
const collectionConfig = this.payload.collections[collection].config;
|
|
8
|
-
const
|
|
8
|
+
const options = {
|
|
9
|
+
...await withSession(this, req),
|
|
10
|
+
lean: true
|
|
11
|
+
};
|
|
9
12
|
const query = await Model.buildQuery({
|
|
10
13
|
locale,
|
|
11
14
|
payload: this.payload,
|
|
12
|
-
session,
|
|
13
15
|
where
|
|
14
16
|
});
|
|
15
|
-
const fields = collectionConfig.flattenedFields;
|
|
16
17
|
const projection = buildProjectionFromSelect({
|
|
17
18
|
adapter: this,
|
|
18
|
-
fields,
|
|
19
|
+
fields: collectionConfig.flattenedFields,
|
|
19
20
|
select
|
|
20
21
|
});
|
|
21
|
-
const
|
|
22
|
+
const aggregate = await buildJoinAggregation({
|
|
22
23
|
adapter: this,
|
|
23
24
|
collection,
|
|
24
25
|
collectionConfig,
|
|
25
26
|
joins,
|
|
27
|
+
limit: 1,
|
|
26
28
|
locale,
|
|
27
29
|
projection,
|
|
28
|
-
|
|
30
|
+
query
|
|
29
31
|
});
|
|
30
32
|
let doc;
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
$match: query
|
|
35
|
-
}
|
|
36
|
-
], {
|
|
37
|
-
session
|
|
38
|
-
});
|
|
39
|
-
cursor.limit(1);
|
|
40
|
-
for (const stage of joinAggregation){
|
|
41
|
-
cursor.addStage(stage);
|
|
42
|
-
}
|
|
43
|
-
[doc] = await cursor.toArray();
|
|
33
|
+
if (aggregate) {
|
|
34
|
+
[doc] = await Model.aggregate(aggregate, options);
|
|
44
35
|
} else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
session
|
|
48
|
-
});
|
|
36
|
+
options.projection = projection;
|
|
37
|
+
doc = await Model.findOne(query, {}, options);
|
|
49
38
|
}
|
|
50
39
|
if (!doc) {
|
|
51
40
|
return null;
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
return doc;
|
|
42
|
+
let result = JSON.parse(JSON.stringify(doc));
|
|
43
|
+
// custom id type reset
|
|
44
|
+
result.id = result._id;
|
|
45
|
+
result = sanitizeInternalFields(result);
|
|
46
|
+
return result;
|
|
60
47
|
};
|
|
61
48
|
|
|
62
49
|
//# sourceMappingURL=findOne.js.map
|
package/dist/findOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOne, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { MongooseQueryOptions, QueryOptions } from 'mongoose'\nimport type { Document, FindOne, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findOne: FindOne = async function findOne(\n this: MongooseAdapter,\n { collection, joins, locale, req = {} as PayloadRequest, select, where },\n) {\n const Model = this.collections[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options: MongooseQueryOptions = {\n ...(await withSession(this, req)),\n lean: true,\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n const projection = buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n })\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection,\n collectionConfig,\n joins,\n limit: 1,\n locale,\n projection,\n query,\n })\n\n let doc\n if (aggregate) {\n ;[doc] = await Model.aggregate(aggregate, options)\n } else {\n ;(options as Record<string, unknown>).projection = projection\n doc = await Model.findOne(query, {}, options)\n }\n\n if (!doc) {\n return null\n }\n\n let result: Document = JSON.parse(JSON.stringify(doc))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildJoinAggregation","buildProjectionFromSelect","sanitizeInternalFields","withSession","findOne","collection","joins","locale","req","select","where","Model","collections","collectionConfig","payload","config","options","lean","query","buildQuery","projection","adapter","fields","flattenedFields","aggregate","limit","doc","result","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,UAAmB,eAAeA,QAE7C,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAExE,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACP,WAAW;IAC1C,MAAMQ,mBAAmB,IAAI,CAACC,OAAO,CAACF,WAAW,CAACP,WAAW,CAACU,MAAM;IACpE,MAAMC,UAAgC;QACpC,GAAI,MAAMb,YAAY,IAAI,EAAEK,IAAI;QAChCS,MAAM;IACR;IAEA,MAAMC,QAAQ,MAAMP,MAAMQ,UAAU,CAAC;QACnCZ;QACAO,SAAS,IAAI,CAACA,OAAO;QACrBJ;IACF;IAEA,MAAMU,aAAanB,0BAA0B;QAC3CoB,SAAS,IAAI;QACbC,QAAQT,iBAAiBU,eAAe;QACxCd;IACF;IAEA,MAAMe,YAAY,MAAMxB,qBAAqB;QAC3CqB,SAAS,IAAI;QACbhB;QACAQ;QACAP;QACAmB,OAAO;QACPlB;QACAa;QACAF;IACF;IAEA,IAAIQ;IACJ,IAAIF,WAAW;QACZ,CAACE,IAAI,GAAG,MAAMf,MAAMa,SAAS,CAACA,WAAWR;IAC5C,OAAO;QACHA,QAAoCI,UAAU,GAAGA;QACnDM,MAAM,MAAMf,MAAMP,OAAO,CAACc,OAAO,CAAC,GAAGF;IACvC;IAEA,IAAI,CAACU,KAAK;QACR,OAAO;IACT;IAEA,IAAIC,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAEjD,uBAAuB;IACvBC,OAAOI,EAAE,GAAGJ,OAAOK,GAAG;IACtBL,SAASzB,uBAAuByB;IAEhC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,SAAS,CAAA;AAW3D,eAAO,MAAM,YAAY,EAAE,YA6G1B,CAAA"}
|
package/dist/findVersions.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { buildVersionCollectionFields } from 'payload';
|
|
2
|
-
import { getSession } from './getSession.js';
|
|
1
|
+
import { buildVersionCollectionFields, flattenWhereToOperators } from 'payload';
|
|
3
2
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
4
3
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { transform } from './utilities/transform.js';
|
|
4
|
+
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
5
|
+
import { withSession } from './withSession.js';
|
|
8
6
|
export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, select, skip, sort: sortArg, where }) {
|
|
9
7
|
const Model = this.versions[collection];
|
|
10
8
|
const collectionConfig = this.payload.collections[collection].config;
|
|
11
|
-
const
|
|
12
|
-
|
|
9
|
+
const options = {
|
|
10
|
+
...await withSession(this, req),
|
|
11
|
+
limit,
|
|
12
|
+
skip
|
|
13
|
+
};
|
|
14
|
+
let hasNearConstraint = false;
|
|
15
|
+
if (where) {
|
|
16
|
+
const constraints = flattenWhereToOperators(where);
|
|
17
|
+
hasNearConstraint = constraints.some((prop)=>Object.keys(prop).some((key)=>key === 'near'));
|
|
18
|
+
}
|
|
13
19
|
let sort;
|
|
14
20
|
if (!hasNearConstraint) {
|
|
15
21
|
sort = buildSortParam({
|
|
@@ -23,42 +29,64 @@ export const findVersions = async function findVersions({ collection, limit, loc
|
|
|
23
29
|
const query = await Model.buildQuery({
|
|
24
30
|
locale,
|
|
25
31
|
payload: this.payload,
|
|
26
|
-
session,
|
|
27
32
|
where
|
|
28
33
|
});
|
|
29
|
-
const versionFields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
|
|
30
34
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
31
35
|
const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
select
|
|
36
|
-
});
|
|
37
|
-
const collation = this.collation ? {
|
|
38
|
-
locale: locale && locale !== 'all' && locale !== '*' ? locale : 'en',
|
|
39
|
-
...this.collation
|
|
40
|
-
} : undefined;
|
|
41
|
-
const result = await findMany({
|
|
42
|
-
adapter: this,
|
|
43
|
-
collation,
|
|
44
|
-
collection: Model.collection,
|
|
36
|
+
const paginationOptions = {
|
|
37
|
+
lean: true,
|
|
38
|
+
leanWithId: true,
|
|
45
39
|
limit,
|
|
40
|
+
options,
|
|
46
41
|
page,
|
|
47
42
|
pagination,
|
|
48
|
-
projection
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
projection: buildProjectionFromSelect({
|
|
44
|
+
adapter: this,
|
|
45
|
+
fields: buildVersionCollectionFields(this.payload.config, collectionConfig, true),
|
|
46
|
+
select
|
|
47
|
+
}),
|
|
52
48
|
sort,
|
|
53
49
|
useEstimatedCount
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
};
|
|
51
|
+
if (this.collation) {
|
|
52
|
+
const defaultLocale = 'en';
|
|
53
|
+
paginationOptions.collation = {
|
|
54
|
+
locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,
|
|
55
|
+
...this.collation
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {
|
|
59
|
+
// Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding
|
|
60
|
+
// a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,
|
|
61
|
+
// which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses
|
|
62
|
+
// the correct indexed field
|
|
63
|
+
paginationOptions.useCustomCountFn = ()=>{
|
|
64
|
+
return Promise.resolve(Model.countDocuments(query, {
|
|
65
|
+
...options,
|
|
66
|
+
hint: {
|
|
67
|
+
_id: 1
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (limit >= 0) {
|
|
73
|
+
paginationOptions.limit = limit;
|
|
74
|
+
// limit must also be set here, it's ignored when pagination is false
|
|
75
|
+
paginationOptions.options.limit = limit;
|
|
76
|
+
// Disable pagination if limit is 0
|
|
77
|
+
if (limit === 0) {
|
|
78
|
+
paginationOptions.pagination = false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const result = await Model.paginate(query, paginationOptions);
|
|
82
|
+
const docs = JSON.parse(JSON.stringify(result.docs));
|
|
83
|
+
return {
|
|
84
|
+
...result,
|
|
85
|
+
docs: docs.map((doc)=>{
|
|
86
|
+
doc.id = doc._id;
|
|
87
|
+
return sanitizeInternalFields(doc);
|
|
88
|
+
})
|
|
89
|
+
};
|
|
62
90
|
};
|
|
63
91
|
|
|
64
92
|
//# sourceMappingURL=findVersions.js.map
|
package/dist/findVersions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { FindVersions, PayloadRequest } from 'payload'\n\nimport { buildVersionCollectionFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { withSession } from './withSession.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n {\n collection,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n select,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const Model = this.versions[collection]\n const collectionConfig = this.payload.collections[collection].config\n const options = {\n ...(await withSession(this, req)),\n limit,\n skip,\n }\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig, true),\n select,\n }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n ...options,\n hint: { _id: 1 },\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n paginationOptions.options.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["buildVersionCollectionFields","flattenWhereToOperators","buildSortParam","buildProjectionFromSelect","sanitizeInternalFields","withSession","findVersions","collection","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","Model","versions","collectionConfig","payload","collections","config","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","flattenedFields","timestamps","query","buildQuery","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","adapter","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","docs","JSON","parse","stringify","map","doc","id"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,uBAAuB,QAAQ,UAAS;AAI/E,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,MAAMC,eAA6B,eAAeA,aAEv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K,SAAS,GAAG;YAC5BnC,QAAQA,UAAUA,WAAW,SAASA,WAAW,MAAMA,SAASoC;YAChE,GAAG,IAAI,CAACD,SAAS;QACnB;IACF;IAEA,IAAI,CAACP,qBAAqBR,OAAOC,IAAI,CAACK,OAAOG,MAAM,KAAK,KAAK,IAAI,CAACQ,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5BP,kBAAkBQ,gBAAgB,GAAG;YACnC,OAAOC,QAAQC,OAAO,CACpB/B,MAAMgC,cAAc,CAACf,OAAO;gBAC1B,GAAGX,OAAO;gBACV2B,MAAM;oBAAEC,KAAK;gBAAE;YACjB;QAEJ;IACF;IAEA,IAAI5C,SAAS,GAAG;QACd+B,kBAAkB/B,KAAK,GAAGA;QAC1B,qEAAqE;QACrE+B,kBAAkBf,OAAO,CAAChB,KAAK,GAAGA;QAElC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACf+B,kBAAkB5B,UAAU,GAAG;QACjC;IACF;IAEA,MAAM0C,SAAS,MAAMnC,MAAMoC,QAAQ,CAACnB,OAAOI;IAC3C,MAAMgB,OAAOC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACL,OAAOE,IAAI;IAElD,OAAO;QACL,GAAGF,MAAM;QACTE,MAAMA,KAAKI,GAAG,CAAC,CAACC;YACdA,IAAIC,EAAE,GAAGD,IAAIR,GAAG;YAChB,OAAOhD,uBAAuBwD;QAChC;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateRelationshipsV2_V3.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"migrateRelationshipsV2_V3.d.ts","sourceRoot":"","sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,cAAc,EAAmB,MAAM,SAAS,CAAA;AAmGrE,wBAAsB,yBAAyB,CAAC,EAC9C,SAAS,EACT,GAAG,GACJ,EAAE;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,cAAc,CAAA;CACpB,GAAG,OAAO,CAAC,IAAI,CAAC,CA+EhB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const migrateModelWithBatching = async ({
|
|
2
|
+
import { sanitizeRelationshipIDs } from '../utilities/sanitizeRelationshipIDs.js';
|
|
3
|
+
import { withSession } from '../withSession.js';
|
|
4
|
+
const migrateModelWithBatching = async ({ batchSize, config, fields, Model, session })=>{
|
|
5
5
|
let hasNext = true;
|
|
6
6
|
let skip = 0;
|
|
7
7
|
while(hasNext){
|
|
@@ -19,12 +19,10 @@ const migrateModelWithBatching = async ({ adapter, batchSize, fields, Model, ses
|
|
|
19
19
|
docs.pop();
|
|
20
20
|
}
|
|
21
21
|
for (const doc of docs){
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
sanitizeRelationshipIDs({
|
|
23
|
+
config,
|
|
24
24
|
data: doc,
|
|
25
|
-
fields
|
|
26
|
-
operation: 'update',
|
|
27
|
-
validateRelationships: false
|
|
25
|
+
fields
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
await Model.collection.bulkWrite(docs.map((doc)=>({
|
|
@@ -79,13 +77,13 @@ export async function migrateRelationshipsV2_V3({ batchSize, req }) {
|
|
|
79
77
|
const { payload } = req;
|
|
80
78
|
const db = payload.db;
|
|
81
79
|
const config = payload.config;
|
|
82
|
-
const session = await
|
|
80
|
+
const { session } = await withSession(db, req);
|
|
83
81
|
for (const collection of payload.config.collections.filter(hasRelationshipOrUploadField)){
|
|
84
82
|
payload.logger.info(`Migrating collection "${collection.slug}"`);
|
|
85
83
|
await migrateModelWithBatching({
|
|
86
|
-
adapter: db,
|
|
87
84
|
batchSize,
|
|
88
|
-
|
|
85
|
+
config,
|
|
86
|
+
fields: collection.fields,
|
|
89
87
|
Model: db.collections[collection.slug],
|
|
90
88
|
session
|
|
91
89
|
});
|
|
@@ -93,9 +91,9 @@ export async function migrateRelationshipsV2_V3({ batchSize, req }) {
|
|
|
93
91
|
if (collection.versions) {
|
|
94
92
|
payload.logger.info(`Migrating collection versions "${collection.slug}"`);
|
|
95
93
|
await migrateModelWithBatching({
|
|
96
|
-
adapter: db,
|
|
97
94
|
batchSize,
|
|
98
|
-
|
|
95
|
+
config,
|
|
96
|
+
fields: buildVersionCollectionFields(config, collection),
|
|
99
97
|
Model: db.versions[collection.slug],
|
|
100
98
|
session
|
|
101
99
|
});
|
|
@@ -115,12 +113,10 @@ export async function migrateRelationshipsV2_V3({ batchSize, req }) {
|
|
|
115
113
|
});
|
|
116
114
|
// in case if the global doesn't exist in the database yet (not saved)
|
|
117
115
|
if (doc) {
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
sanitizeRelationshipIDs({
|
|
117
|
+
config,
|
|
120
118
|
data: doc,
|
|
121
|
-
fields: global.
|
|
122
|
-
operation: 'update',
|
|
123
|
-
validateRelationships: false
|
|
119
|
+
fields: global.fields
|
|
124
120
|
});
|
|
125
121
|
await GlobalsModel.collection.updateOne({
|
|
126
122
|
globalType: global.slug
|
|
@@ -134,9 +130,9 @@ export async function migrateRelationshipsV2_V3({ batchSize, req }) {
|
|
|
134
130
|
if (global.versions) {
|
|
135
131
|
payload.logger.info(`Migrating global versions "${global.slug}"`);
|
|
136
132
|
await migrateModelWithBatching({
|
|
137
|
-
adapter: db,
|
|
138
133
|
batchSize,
|
|
139
|
-
|
|
134
|
+
config,
|
|
135
|
+
fields: buildVersionGlobalFields(config, global),
|
|
140
136
|
Model: db.versions[global.slug],
|
|
141
137
|
session
|
|
142
138
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"sourcesContent":["import type { ClientSession, Model } from 'mongoose'\nimport type { Field,
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/migrateRelationshipsV2_V3.ts"],"sourcesContent":["import type { ClientSession, Model } from 'mongoose'\nimport type { Field, PayloadRequest, SanitizedConfig } from 'payload'\n\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { sanitizeRelationshipIDs } from '../utilities/sanitizeRelationshipIDs.js'\nimport { withSession } from '../withSession.js'\n\nconst migrateModelWithBatching = async ({\n batchSize,\n config,\n fields,\n Model,\n session,\n}: {\n batchSize: number\n config: SanitizedConfig\n fields: Field[]\n Model: Model<any>\n session: ClientSession\n}): Promise<void> => {\n let hasNext = true\n let skip = 0\n\n while (hasNext) {\n const docs = await Model.find(\n {},\n {},\n {\n lean: true,\n limit: batchSize + 1,\n session,\n skip,\n },\n )\n\n if (docs.length === 0) {\n break\n }\n\n hasNext = docs.length > batchSize\n\n if (hasNext) {\n docs.pop()\n }\n\n for (const doc of docs) {\n sanitizeRelationshipIDs({ config, data: doc, fields })\n }\n\n await Model.collection.bulkWrite(\n docs.map((doc) => ({\n updateOne: {\n filter: { _id: doc._id },\n update: {\n $set: doc,\n },\n },\n })),\n { session },\n )\n\n skip += batchSize\n }\n}\n\nconst hasRelationshipOrUploadField = ({ fields }: { fields: Field[] }): boolean => {\n for (const field of fields) {\n if (field.type === 'relationship' || field.type === 'upload') {\n return true\n }\n\n if ('fields' in field) {\n if (hasRelationshipOrUploadField({ fields: field.fields })) {\n return true\n }\n }\n\n if ('blocks' in field) {\n for (const block of field.blocks) {\n if (hasRelationshipOrUploadField({ fields: block.fields })) {\n return true\n }\n }\n }\n\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if (hasRelationshipOrUploadField({ fields: tab.fields })) {\n return true\n }\n }\n }\n }\n\n return false\n}\n\nexport async function migrateRelationshipsV2_V3({\n batchSize,\n req,\n}: {\n batchSize: number\n req: PayloadRequest\n}): Promise<void> {\n const { payload } = req\n const db = payload.db as MongooseAdapter\n const config = payload.config\n\n const { session } = await withSession(db, req)\n\n for (const collection of payload.config.collections.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating collection \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: collection.fields,\n Model: db.collections[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection \"${collection.slug}\"`)\n\n if (collection.versions) {\n payload.logger.info(`Migrating collection versions \"${collection.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionCollectionFields(config, collection),\n Model: db.versions[collection.slug],\n session,\n })\n\n payload.logger.info(`Migrated collection versions \"${collection.slug}\"`)\n }\n }\n\n const { globals: GlobalsModel } = db\n\n for (const global of payload.config.globals.filter(hasRelationshipOrUploadField)) {\n payload.logger.info(`Migrating global \"${global.slug}\"`)\n\n const doc = await GlobalsModel.findOne<Record<string, unknown>>(\n {\n globalType: {\n $eq: global.slug,\n },\n },\n {},\n { lean: true, session },\n )\n\n // in case if the global doesn't exist in the database yet (not saved)\n if (doc) {\n sanitizeRelationshipIDs({ config, data: doc, fields: global.fields })\n\n await GlobalsModel.collection.updateOne(\n {\n globalType: global.slug,\n },\n { $set: doc },\n { session },\n )\n }\n\n payload.logger.info(`Migrated global \"${global.slug}\"`)\n\n if (global.versions) {\n payload.logger.info(`Migrating global versions \"${global.slug}\"`)\n\n await migrateModelWithBatching({\n batchSize,\n config,\n fields: buildVersionGlobalFields(config, global),\n Model: db.versions[global.slug],\n session,\n })\n\n payload.logger.info(`Migrated global versions \"${global.slug}\"`)\n }\n }\n}\n"],"names":["buildVersionCollectionFields","buildVersionGlobalFields","sanitizeRelationshipIDs","withSession","migrateModelWithBatching","batchSize","config","fields","Model","session","hasNext","skip","docs","find","lean","limit","length","pop","doc","data","collection","bulkWrite","map","updateOne","filter","_id","update","$set","hasRelationshipOrUploadField","field","type","block","blocks","tab","tabs","migrateRelationshipsV2_V3","req","payload","db","collections","logger","info","slug","versions","globals","GlobalsModel","global","findOne","globalType","$eq"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAIhF,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,WAAW,QAAQ,oBAAmB;AAE/C,MAAMC,2BAA2B,OAAO,EACtCC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,OAAO,EAOR;IACC,IAAIC,UAAU;IACd,IAAIC,OAAO;IAEX,MAAOD,QAAS;QACd,MAAME,OAAO,MAAMJ,MAAMK,IAAI,CAC3B,CAAC,GACD,CAAC,GACD;YACEC,MAAM;YACNC,OAAOV,YAAY;YACnBI;YACAE;QACF;QAGF,IAAIC,KAAKI,MAAM,KAAK,GAAG;YACrB;QACF;QAEAN,UAAUE,KAAKI,MAAM,GAAGX;QAExB,IAAIK,SAAS;YACXE,KAAKK,GAAG;QACV;QAEA,KAAK,MAAMC,OAAON,KAAM;YACtBV,wBAAwB;gBAAEI;gBAAQa,MAAMD;gBAAKX;YAAO;QACtD;QAEA,MAAMC,MAAMY,UAAU,CAACC,SAAS,CAC9BT,KAAKU,GAAG,CAAC,CAACJ,MAAS,CAAA;gBACjBK,WAAW;oBACTC,QAAQ;wBAAEC,KAAKP,IAAIO,GAAG;oBAAC;oBACvBC,QAAQ;wBACNC,MAAMT;oBACR;gBACF;YACF,CAAA,IACA;YAAET;QAAQ;QAGZE,QAAQN;IACV;AACF;AAEA,MAAMuB,+BAA+B,CAAC,EAAErB,MAAM,EAAuB;IACnE,KAAK,MAAMsB,SAAStB,OAAQ;QAC1B,IAAIsB,MAAMC,IAAI,KAAK,kBAAkBD,MAAMC,IAAI,KAAK,UAAU;YAC5D,OAAO;QACT;QAEA,IAAI,YAAYD,OAAO;YACrB,IAAID,6BAA6B;gBAAErB,QAAQsB,MAAMtB,MAAM;YAAC,IAAI;gBAC1D,OAAO;YACT;QACF;Q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ACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { withSession } from '../withSession.js';
|
|
2
2
|
export async function migrateVersionsV1_V2({ req }) {
|
|
3
3
|
const { payload } = req;
|
|
4
|
-
const session = await
|
|
4
|
+
const { session } = await withSession(payload.db, req);
|
|
5
5
|
// For each collection
|
|
6
6
|
for (const { slug, versions } of payload.config.collections){
|
|
7
7
|
if (versions?.drafts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/predefinedMigrations/migrateVersionsV1_V2.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/predefinedMigrations/migrateVersionsV1_V2.ts"],"sourcesContent":["import type { ClientSession } from 'mongoose'\nimport type { Payload, PayloadRequest } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { withSession } from '../withSession.js'\n\nexport async function migrateVersionsV1_V2({ req }: { req: PayloadRequest }) {\n const { payload } = req\n\n const { session } = await withSession(payload.db as MongooseAdapter, req)\n\n // For each collection\n\n for (const { slug, versions } of payload.config.collections) {\n if (versions?.drafts) {\n await migrateCollectionDocs({ slug, payload, session })\n\n payload.logger.info(`Migrated the \"${slug}\" collection.`)\n }\n }\n\n // For each global\n for (const { slug, versions } of payload.config.globals) {\n if (versions) {\n const VersionsModel = payload.db.versions[slug]\n\n await VersionsModel.findOneAndUpdate(\n {},\n { latest: true },\n {\n session,\n sort: { updatedAt: -1 },\n },\n ).exec()\n\n payload.logger.info(`Migrated the \"${slug}\" global.`)\n }\n }\n}\n\nasync function migrateCollectionDocs({\n slug,\n docsAtATime = 100,\n payload,\n session,\n}: {\n docsAtATime?: number\n payload: Payload\n session: ClientSession\n slug: string\n}) {\n const VersionsModel = payload.db.versions[slug]\n const remainingDocs = await VersionsModel.aggregate(\n [\n // Sort so that newest are first\n {\n $sort: {\n updatedAt: -1,\n },\n },\n // Group by parent ID\n // take the $first of each\n {\n $group: {\n _id: '$parent',\n _versionID: { $first: '$_id' },\n createdAt: { $first: '$createdAt' },\n latest: { $first: '$latest' },\n updatedAt: { $first: '$updatedAt' },\n version: { $first: '$version' },\n },\n },\n {\n $match: {\n latest: { $eq: null },\n },\n },\n {\n $limit: docsAtATime,\n },\n ],\n {\n allowDiskUse: true,\n session,\n },\n ).exec()\n\n if (!remainingDocs || remainingDocs.length === 0) {\n const newVersions = await VersionsModel.find(\n {\n latest: {\n $eq: true,\n },\n },\n undefined,\n { session },\n )\n\n if (newVersions?.length) {\n payload.logger.info(\n `Migrated ${newVersions.length} documents in the \"${slug}\" versions collection.`,\n )\n }\n\n return\n }\n\n const remainingDocIds = remainingDocs.map((doc) => doc._versionID)\n\n await VersionsModel.updateMany(\n {\n _id: {\n $in: remainingDocIds,\n },\n },\n {\n latest: true,\n },\n {\n session,\n },\n )\n\n await migrateCollectionDocs({ slug, payload, session })\n}\n"],"names":["withSession","migrateVersionsV1_V2","req","payload","session","db","slug","versions","config","collections","drafts","migrateCollectionDocs","logger","info","globals","VersionsModel","findOneAndUpdate","latest","sort","updatedAt","exec","docsAtATime","remainingDocs","aggregate","$sort","$group","_id","_versionID","$first","createdAt","version","$match","$eq","$limit","allowDiskUse","length","newVersions","find","undefined","remainingDocIds","map","doc","updateMany","$in"],"mappings":"AAKA,SAASA,WAAW,QAAQ,oBAAmB;AAE/C,OAAO,eAAeC,qBAAqB,EAAEC,GAAG,EAA2B;IACzE,MAAM,EAAEC,OAAO,EAAE,GAAGD;IAEpB,MAAM,EAAEE,OAAO,EAAE,GAAG,MAAMJ,YAAYG,QAAQE,EAAE,EAAqBH;IAErE,sBAAsB;IAEtB,KAAK,MAAM,EAAEI,IAAI,EAAEC,QAAQ,EAAE,IAAIJ,QAAQK,MAAM,CAACC,WAAW,CAAE;QAC3D,IAAIF,UAAUG,QAAQ;YACpB,MAAMC,sBAAsB;gBA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