@payloadcms/db-mongodb 3.24.0-canary.7d9fbaf → 3.24.0-canary.80e034e
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 +5 -2
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +5 -3
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +5 -3
- package/dist/countVersions.js.map +1 -1
- package/dist/create.js +15 -15
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +15 -14
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +26 -23
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +26 -31
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +5 -2
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +17 -9
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +5 -2
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +13 -12
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +15 -11
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +14 -14
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +13 -8
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +14 -13
- package/dist/findVersions.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1 -3
- package/dist/init.js.map +1 -1
- package/dist/models/buildCollectionSchema.d.ts.map +1 -1
- package/dist/models/buildCollectionSchema.js +2 -3
- package/dist/models/buildCollectionSchema.js.map +1 -1
- package/dist/models/buildGlobalModel.d.ts.map +1 -1
- package/dist/models/buildGlobalModel.js +1 -2
- package/dist/models/buildGlobalModel.js.map +1 -1
- package/dist/models/buildSchema.js +2 -0
- package/dist/models/buildSchema.js.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +12 -7
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +6 -9
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +11 -35
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +1 -1
- package/dist/queries/buildSortParam.d.ts.map +1 -1
- package/dist/queries/buildSortParam.js.map +1 -1
- package/dist/queries/getBuildQueryPlugin.d.ts +14 -0
- package/dist/queries/getBuildQueryPlugin.d.ts.map +1 -0
- package/dist/queries/getBuildQueryPlugin.js +40 -0
- package/dist/queries/getBuildQueryPlugin.js.map +1 -0
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +19 -17
- package/dist/queryDrafts.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +15 -12
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +21 -15
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.js +20 -11
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +21 -15
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/buildJoinAggregation.d.ts.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +150 -4
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.js +14 -16
- package/dist/utilities/buildProjectionFromSelect.js.map +1 -1
- package/dist/utilities/transform.d.ts +27 -0
- package/dist/utilities/transform.d.ts.map +1 -0
- package/dist/utilities/transform.js +224 -0
- package/dist/utilities/transform.js.map +1 -0
- package/dist/utilities/{sanitizeRelationshipIDs.spec.js → transform.spec.js} +11 -5
- package/dist/utilities/transform.spec.js.map +1 -0
- package/package.json +3 -3
- package/dist/utilities/sanitizeInternalFields.d.ts +0 -2
- package/dist/utilities/sanitizeInternalFields.d.ts.map +0 -1
- package/dist/utilities/sanitizeInternalFields.js +0 -20
- package/dist/utilities/sanitizeInternalFields.js.map +0 -1
- package/dist/utilities/sanitizeRelationshipIDs.d.ts +0 -10
- package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +0 -1
- package/dist/utilities/sanitizeRelationshipIDs.js +0 -130
- package/dist/utilities/sanitizeRelationshipIDs.js.map +0 -1
- package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,cAAc,EAAE,MAAM,SAAS,CAAA;AAO3E,eAAO,MAAM,cAAc,EAAE,cAoB5B,CAAA"}
|
package/dist/deleteVersions.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { buildVersionCollectionFields } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
1
3
|
import { getSession } from './utilities/getSession.js';
|
|
2
4
|
export const deleteVersions = async function deleteVersions({ collection, locale, req, where }) {
|
|
3
5
|
const VersionsModel = this.versions[collection];
|
|
4
6
|
const session = await getSession(this, req);
|
|
5
|
-
const query = await
|
|
7
|
+
const query = await buildQuery({
|
|
8
|
+
adapter: this,
|
|
9
|
+
fields: buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config, true),
|
|
6
10
|
locale,
|
|
7
|
-
payload: this.payload,
|
|
8
11
|
where
|
|
9
12
|
});
|
|
10
13
|
await VersionsModel.deleteMany(query, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import { buildVersionCollectionFields, type DeleteVersions } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { getSession } from './utilities/getSession.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersions(\n this: MongooseAdapter,\n { collection, locale, req, where },\n) {\n const VersionsModel = this.versions[collection]\n\n const session = await getSession(this, req)\n\n const query = await buildQuery({\n adapter: this,\n fields: buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\n true,\n ),\n locale,\n where,\n })\n\n await VersionsModel.deleteMany(query, { session })\n}\n"],"names":["buildVersionCollectionFields","buildQuery","getSession","deleteVersions","collection","locale","req","where","VersionsModel","versions","session","query","adapter","fields","payload","config","collections","deleteMany"],"mappings":"AAAA,SAASA,4BAA4B,QAA6B,UAAS;AAI3E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,iBAAiC,eAAeA,eAE3D,EAAEC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAElC,MAAMC,gBAAgB,IAAI,CAACC,QAAQ,CAACL,WAAW;IAE/C,MAAMM,UAAU,MAAMR,WAAW,IAAI,EAAEI;IAEvC,MAAMK,QAAQ,MAAMV,WAAW;QAC7BW,SAAS,IAAI;QACbC,QAAQb,6BACN,IAAI,CAACc,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACE,WAAW,CAACZ,WAAW,CAACW,MAAM,EAC3C;QAEFV;QACAE;IACF;IAEA,MAAMC,cAAcS,UAAU,CAACN,OAAO;QAAED;IAAQ;AAClD,EAAC"}
|
package/dist/find.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAanC,eAAO,MAAM,IAAI,EAAE,IAiIlB,CAAA"}
|
package/dist/find.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { flattenWhereToOperators } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
4
|
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
|
4
5
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
5
6
|
import { getSession } from './utilities/getSession.js';
|
|
6
|
-
import {
|
|
7
|
+
import { transform } from './utilities/transform.js';
|
|
7
8
|
export const find = async function find({ collection, joins = {}, limit = 0, locale, page, pagination, projection, req, select, sort: sortArg, where }) {
|
|
8
9
|
const Model = this.collections[collection];
|
|
9
10
|
const collectionConfig = this.payload.collections[collection].config;
|
|
@@ -19,14 +20,15 @@ export const find = async function find({ collection, joins = {}, limit = 0, loc
|
|
|
19
20
|
config: this.payload.config,
|
|
20
21
|
fields: collectionConfig.flattenedFields,
|
|
21
22
|
locale,
|
|
22
|
-
parentIsLocalized: false,
|
|
23
23
|
sort: sortArg || collectionConfig.defaultSort,
|
|
24
24
|
timestamps: true
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
const query = await
|
|
27
|
+
const query = await buildQuery({
|
|
28
|
+
adapter: this,
|
|
29
|
+
collectionSlug: collection,
|
|
30
|
+
fields: this.payload.collections[collection].config.flattenedFields,
|
|
28
31
|
locale,
|
|
29
|
-
payload: this.payload,
|
|
30
32
|
where
|
|
31
33
|
});
|
|
32
34
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
@@ -95,14 +97,13 @@ export const find = async function find({ collection, joins = {}, limit = 0, loc
|
|
|
95
97
|
} else {
|
|
96
98
|
result = await Model.paginate(query, paginationOptions);
|
|
97
99
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
100
|
+
transform({
|
|
101
|
+
adapter: this,
|
|
102
|
+
data: result.docs,
|
|
103
|
+
fields: this.payload.collections[collection].config.fields,
|
|
104
|
+
operation: 'read'
|
|
105
|
+
});
|
|
106
|
+
return result;
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
//# sourceMappingURL=find.js.map
|
package/dist/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Find } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Find } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const find: Find = async function find(\n this: MongooseAdapter,\n {\n collection,\n joins = {},\n limit = 0,\n locale,\n page,\n pagination,\n projection,\n req,\n select,\n sort: sortArg,\n where,\n },\n) {\n const Model = this.collections[collection]\n const collectionConfig = this.payload.collections[collection].config\n\n const session = await getSession(this, req)\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 || collectionConfig.defaultSort,\n timestamps: true,\n })\n }\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug: collection,\n fields: this.payload.collections[collection].config.flattenedFields,\n locale,\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 options: {\n session,\n },\n page,\n pagination,\n projection,\n sort,\n useEstimatedCount,\n }\n\n if (select) {\n paginationOptions.projection = buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n })\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 hint: { _id: 1 },\n session,\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 let result\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection,\n collectionConfig,\n joins,\n locale,\n query,\n })\n // build join aggregation\n if (aggregate) {\n result = await Model.aggregatePaginate(Model.aggregate(aggregate), paginationOptions)\n } else {\n result = await Model.paginate(query, paginationOptions)\n }\n\n transform({\n adapter: this,\n data: result.docs,\n fields: this.payload.collections[collection].config.fields,\n operation: 'read',\n })\n\n return result\n}\n"],"names":["flattenWhereToOperators","buildQuery","buildSortParam","buildJoinAggregation","buildProjectionFromSelect","getSession","transform","find","collection","joins","limit","locale","page","pagination","projection","req","select","sort","sortArg","where","Model","collections","collectionConfig","payload","config","session","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","flattenedFields","defaultSort","timestamps","query","adapter","collectionSlug","useEstimatedCount","length","paginationOptions","lean","leanWithId","options","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","aggregate","aggregatePaginate","paginate","data","docs","operation"],"mappings":"AAGA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,oBAAoB,QAAQ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,IAAI,CAACV,OAAO,CAACF,WAAW,CAACb,WAAW,CAACgB,MAAM,CAACS,MAAM;QAC1D4B,WAAW;IACb;IAEA,OAAON;AACT,EAAC"}
|
package/dist/findGlobal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAWzC,eAAO,MAAM,UAAU,EAAE,UAuCxB,CAAA"}
|
package/dist/findGlobal.js
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
import { combineQueries } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
3
4
|
import { getSession } from './utilities/getSession.js';
|
|
4
|
-
import {
|
|
5
|
+
import { transform } from './utilities/transform.js';
|
|
5
6
|
export const findGlobal = async function findGlobal({ slug, locale, req, select, where }) {
|
|
6
7
|
const Model = this.globals;
|
|
8
|
+
const globalConfig = this.payload.globals.config.find((each)=>each.slug === slug);
|
|
9
|
+
const fields = globalConfig.flattenedFields;
|
|
7
10
|
const options = {
|
|
8
11
|
lean: true,
|
|
9
12
|
select: buildProjectionFromSelect({
|
|
10
13
|
adapter: this,
|
|
11
|
-
fields
|
|
14
|
+
fields,
|
|
12
15
|
select
|
|
13
16
|
}),
|
|
14
17
|
session: await getSession(this, req)
|
|
15
18
|
};
|
|
16
|
-
const query = await
|
|
19
|
+
const query = await buildQuery({
|
|
20
|
+
adapter: this,
|
|
21
|
+
fields,
|
|
17
22
|
globalSlug: slug,
|
|
18
23
|
locale,
|
|
19
|
-
payload: this.payload,
|
|
20
24
|
where: combineQueries({
|
|
21
25
|
globalType: {
|
|
22
26
|
equals: slug
|
|
23
27
|
}
|
|
24
28
|
}, where)
|
|
25
29
|
});
|
|
26
|
-
|
|
30
|
+
const doc = await Model.findOne(query, {}, options);
|
|
27
31
|
if (!doc) {
|
|
28
32
|
return null;
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
transform({
|
|
35
|
+
adapter: this,
|
|
36
|
+
data: doc,
|
|
37
|
+
fields: globalConfig.fields,
|
|
38
|
+
operation: 'read'
|
|
39
|
+
});
|
|
36
40
|
return doc;
|
|
37
41
|
};
|
|
38
42
|
|
package/dist/findGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { FindGlobal } from 'payload'\n\nimport { combineQueries } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { FindGlobal } from 'payload'\n\nimport { combineQueries } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: MongooseAdapter,\n { slug, locale, req, select, where },\n) {\n const Model = this.globals\n const globalConfig = this.payload.globals.config.find((each) => each.slug === slug)\n const fields = globalConfig.flattenedFields\n const options: QueryOptions = {\n lean: true,\n select: buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await buildQuery({\n adapter: this,\n fields,\n globalSlug: slug,\n locale,\n where: combineQueries({ globalType: { equals: slug } }, where),\n })\n\n const doc = (await Model.findOne(query, {}, options)) as any\n\n if (!doc) {\n return null\n }\n\n transform({\n adapter: this,\n data: doc,\n fields: globalConfig.fields,\n operation: 'read',\n })\n\n return doc\n}\n"],"names":["combineQueries","buildQuery","buildProjectionFromSelect","getSession","transform","findGlobal","slug","locale","req","select","where","Model","globals","globalConfig","payload","config","find","each","fields","flattenedFields","options","lean","adapter","session","query","globalSlug","globalType","equals","doc","findOne","data","operation"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAEpC,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACF,OAAO,CAACG,MAAM,CAACC,IAAI,CAAC,CAACC,OAASA,KAAKX,IAAI,KAAKA;IAC9E,MAAMY,SAASL,aAAaM,eAAe;IAC3C,MAAMC,UAAwB;QAC5BC,MAAM;QACNZ,QAAQP,0BAA0B;YAChCoB,SAAS,IAAI;YACbJ;YACAT;QACF;QACAc,SAAS,MAAMpB,WAAW,IAAI,EAAEK;IAClC;IAEA,MAAMgB,QAAQ,MAAMvB,WAAW;QAC7BqB,SAAS,IAAI;QACbJ;QACAO,YAAYnB;QACZC;QACAG,OAAOV,eAAe;YAAE0B,YAAY;gBAAEC,QAAQrB;YAAK;QAAE,GAAGI;IAC1D;IAEA,MAAMkB,MAAO,MAAMjB,MAAMkB,OAAO,CAACL,OAAO,CAAC,GAAGJ;IAE5C,IAAI,CAACQ,KAAK;QACR,OAAO;IACT;IAEAxB,UAAU;QACRkB,SAAS,IAAI;QACbQ,MAAMF;QACNV,QAAQL,aAAaK,MAAM;QAC3Ba,WAAW;IACb;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAYjD,eAAO,MAAM,kBAAkB,EAAE,kBAkGhC,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { buildVersionGlobalFields, flattenWhereToOperators } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
4
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
4
5
|
import { getSession } from './utilities/getSession.js';
|
|
5
|
-
import {
|
|
6
|
+
import { transform } from './utilities/transform.js';
|
|
6
7
|
export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req, select, skip, sort: sortArg, where }) {
|
|
8
|
+
const globalConfig = this.payload.globals.config.find(({ slug })=>slug === global);
|
|
7
9
|
const Model = this.versions[global];
|
|
8
|
-
const versionFields = buildVersionGlobalFields(this.payload.config,
|
|
10
|
+
const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true);
|
|
9
11
|
const session = await getSession(this, req);
|
|
10
12
|
const options = {
|
|
11
13
|
limit,
|
|
@@ -23,15 +25,14 @@ export const findGlobalVersions = async function findGlobalVersions({ global, li
|
|
|
23
25
|
config: this.payload.config,
|
|
24
26
|
fields: versionFields,
|
|
25
27
|
locale,
|
|
26
|
-
parentIsLocalized: false,
|
|
27
28
|
sort: sortArg || '-updatedAt',
|
|
28
29
|
timestamps: true
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
|
-
const query = await
|
|
32
|
-
|
|
32
|
+
const query = await buildQuery({
|
|
33
|
+
adapter: this,
|
|
34
|
+
fields: versionFields,
|
|
33
35
|
locale,
|
|
34
|
-
payload: this.payload,
|
|
35
36
|
where
|
|
36
37
|
});
|
|
37
38
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
@@ -82,14 +83,13 @@ export const findGlobalVersions = async function findGlobalVersions({ global, li
|
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
85
|
const result = await Model.paginate(query, paginationOptions);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
86
|
+
transform({
|
|
87
|
+
adapter: this,
|
|
88
|
+
data: result.docs,
|
|
89
|
+
fields: buildVersionGlobalFields(this.payload.config, globalConfig),
|
|
90
|
+
operation: 'read'
|
|
91
|
+
});
|
|
92
|
+
return result;
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
//# sourceMappingURL=findGlobalVersions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindGlobalVersions } 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 { getSession } from './utilities/getSession.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindGlobalVersions } from 'payload'\n\nimport { buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n { global, limit, locale, page, pagination, req, select, skip, sort: sortArg, where },\n) {\n const globalConfig = this.payload.globals.config.find(({ slug }) => slug === global)\n const Model = this.versions[global]\n const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\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 buildQuery({\n adapter: this,\n fields: versionFields,\n locale,\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 hint: { _id: 1 },\n session,\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\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionGlobalFields(this.payload.config, globalConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getSession","transform","findGlobalVersions","global","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","Model","versions","versionFields","session","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","adapter","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAASA,wBAAwB,EAAEC,uBAAuB,QAAQ,UAAS;AAI3E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EAAEC,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,GAAG,EAAEC,MAAM,EAAEC,IAAI,EAAEC,MAAMC,OAAO,EAAEC,KAAK,EAAE;IAEpF,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EA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,IAAI,CAACO,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5BN,kBAAkBO,gBAAgB,GAAG;YACnC,OAAOC,QAAQC,OAAO,CACpB3B,MAAM4B,cAAc,CAACd,OAAO;gBAC1Be,MAAM;oBAAEC,KAAK;gBAAE;gBACf3B;YACF;QAEJ;IACF;IAEA,IAAInB,SAAS,GAAG;QACdkC,kBAAkBlC,KAAK,GAAGA;QAC1B,qEAAqE;QACrEkC,kBAAkBd,OAAO,CAACpB,KAAK,GAAGA;QAElC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACfkC,kBAAkB/B,UAAU,GAAG;QACjC;IACF;IAEA,MAAM4C,SAAS,MAAM/B,MAAMgC,QAAQ,CAAClB,OAAOI;IAE3CrC,UAAU;QACRkC,SAAS,IAAI;QACbkB,MAAMF,OAAOG,IAAI;QACjBtB,QAAQrC,yBAAyB,IAAI,CAACoB,OAAO,CAACE,MAAM,EAAEH;QACtDyC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
|
package/dist/findOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAUtC,eAAO,MAAM,OAAO,EAAE,OAoDrB,CAAA"}
|
package/dist/findOne.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
1
2
|
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
|
2
3
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
3
4
|
import { getSession } from './utilities/getSession.js';
|
|
4
|
-
import {
|
|
5
|
+
import { transform } from './utilities/transform.js';
|
|
5
6
|
export const findOne = async function findOne({ collection, joins, locale, req, select, where }) {
|
|
6
7
|
const Model = this.collections[collection];
|
|
7
8
|
const collectionConfig = this.payload.collections[collection].config;
|
|
@@ -10,9 +11,11 @@ export const findOne = async function findOne({ collection, joins, locale, req,
|
|
|
10
11
|
lean: true,
|
|
11
12
|
session
|
|
12
13
|
};
|
|
13
|
-
const query = await
|
|
14
|
+
const query = await buildQuery({
|
|
15
|
+
adapter: this,
|
|
16
|
+
collectionSlug: collection,
|
|
17
|
+
fields: collectionConfig.flattenedFields,
|
|
14
18
|
locale,
|
|
15
|
-
payload: this.payload,
|
|
16
19
|
where
|
|
17
20
|
});
|
|
18
21
|
const projection = buildProjectionFromSelect({
|
|
@@ -44,11 +47,13 @@ export const findOne = async function findOne({ collection, joins, locale, req,
|
|
|
44
47
|
if (!doc) {
|
|
45
48
|
return null;
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
transform({
|
|
51
|
+
adapter: this,
|
|
52
|
+
data: doc,
|
|
53
|
+
fields: collectionConfig.fields,
|
|
54
|
+
operation: 'read'
|
|
55
|
+
});
|
|
56
|
+
return doc;
|
|
52
57
|
};
|
|
53
58
|
|
|
54
59
|
//# sourceMappingURL=findOne.js.map
|
package/dist/findOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { AggregateOptions, QueryOptions } from 'mongoose'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { AggregateOptions, QueryOptions } from 'mongoose'\nimport type { FindOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findOne: FindOne = async function findOne(\n this: MongooseAdapter,\n { collection, joins, locale, req, select, where },\n) {\n const Model = this.collections[collection]\n const collectionConfig = this.payload.collections[collection].config\n const session = await getSession(this, req)\n const options: AggregateOptions & QueryOptions = {\n lean: true,\n session,\n }\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug: collection,\n fields: collectionConfig.flattenedFields,\n locale,\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, { session })\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 transform({ adapter: this, data: doc, fields: collectionConfig.fields, operation: 'read' })\n\n return doc\n}\n"],"names":["buildQuery","buildJoinAggregation","buildProjectionFromSelect","getSession","transform","findOne","collection","joins","locale","req","select","where","Model","collections","collectionConfig","payload","config","session","options","lean","query","adapter","collectionSlug","fields","flattenedFields","projection","aggregate","limit","doc","data","operation"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,UAAmB,eAAeA,QAE7C,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAEjD,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACP,WAAW;IAC1C,MAAMQ,mBAAmB,IAAI,CAACC,OAAO,CAACF,WAAW,CAACP,WAAW,CAACU,MAAM;IACpE,MAAMC,UAAU,MAAMd,WAAW,IAAI,EAAEM;IACvC,MAAMS,UAA2C;QAC/CC,MAAM;QACNF;IACF;IAEA,MAAMG,QAAQ,MAAMpB,WAAW;QAC7BqB,SAAS,IAAI;QACbC,gBAAgBhB;QAChBiB,QAAQT,iBAAiBU,eAAe;QACxChB;QACAG;IACF;IAEA,MAAMc,aAAavB,0BAA0B;QAC3CmB,SAAS,IAAI;QACbE,QAAQT,iBAAiBU,eAAe;QACxCd;IACF;IAEA,MAAMgB,YAAY,MAAMzB,qBAAqB;QAC3CoB,SAAS,IAAI;QACbf;QACAQ;QACAP;QACAoB,OAAO;QACPnB;QACAiB;QACAL;IACF;IAEA,IAAIQ;IACJ,IAAIF,WAAW;;QACZ,CAACE,IAAI,GAAG,MAAMhB,MAAMc,SAAS,CAACA,WAAW;YAAET;QAAQ;IACtD,OAAO;;QACHC,QAAoCO,UAAU,GAAGA;QACnDG,MAAM,MAAMhB,MAAMP,OAAO,CAACe,OAAO,CAAC,GAAGF;IACvC;IAEA,IAAI,CAACU,KAAK;QACR,OAAO;IACT;IAEAxB,UAAU;QAAEiB,SAAS,IAAI;QAAEQ,MAAMD;QAAKL,QAAQT,iBAAiBS,MAAM;QAAEO,WAAW;IAAO;IAEzF,OAAOF;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAY3C,eAAO,MAAM,YAAY,EAAE,YAsG1B,CAAA"}
|
package/dist/findVersions.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { buildVersionCollectionFields, flattenWhereToOperators } from 'payload';
|
|
2
|
+
import { buildQuery } from './queries/buildQuery.js';
|
|
2
3
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
4
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
4
5
|
import { getSession } from './utilities/getSession.js';
|
|
5
|
-
import {
|
|
6
|
+
import { transform } from './utilities/transform.js';
|
|
6
7
|
export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, select, skip, sort: sortArg, where }) {
|
|
7
8
|
const Model = this.versions[collection];
|
|
8
9
|
const collectionConfig = this.payload.collections[collection].config;
|
|
@@ -23,14 +24,15 @@ export const findVersions = async function findVersions({ collection, limit, loc
|
|
|
23
24
|
config: this.payload.config,
|
|
24
25
|
fields: collectionConfig.flattenedFields,
|
|
25
26
|
locale,
|
|
26
|
-
parentIsLocalized: false,
|
|
27
27
|
sort: sortArg || '-updatedAt',
|
|
28
28
|
timestamps: true
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
const
|
|
31
|
+
const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true);
|
|
32
|
+
const query = await buildQuery({
|
|
33
|
+
adapter: this,
|
|
34
|
+
fields,
|
|
32
35
|
locale,
|
|
33
|
-
payload: this.payload,
|
|
34
36
|
where
|
|
35
37
|
});
|
|
36
38
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
@@ -44,7 +46,7 @@ export const findVersions = async function findVersions({ collection, limit, loc
|
|
|
44
46
|
pagination,
|
|
45
47
|
projection: buildProjectionFromSelect({
|
|
46
48
|
adapter: this,
|
|
47
|
-
fields
|
|
49
|
+
fields,
|
|
48
50
|
select
|
|
49
51
|
}),
|
|
50
52
|
sort,
|
|
@@ -81,14 +83,13 @@ export const findVersions = async function findVersions({ collection, limit, loc
|
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
const result = await Model.paginate(query, paginationOptions);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
86
|
+
transform({
|
|
87
|
+
adapter: this,
|
|
88
|
+
data: result.docs,
|
|
89
|
+
fields: buildVersionCollectionFields(this.payload.config, collectionConfig),
|
|
90
|
+
operation: 'read'
|
|
91
|
+
});
|
|
92
|
+
return result;
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
//# sourceMappingURL=findVersions.js.map
|
package/dist/findVersions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindVersions } 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 { getSession } from './utilities/getSession.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindVersions } from 'payload'\n\nimport { buildVersionCollectionFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n { collection, limit, locale, page, pagination, req = {}, select, skip, sort: sortArg, where },\n) {\n const Model = this.versions[collection]\n const collectionConfig = this.payload.collections[collection].config\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\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 fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const query = await buildQuery({\n adapter: this,\n fields,\n locale,\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,\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 hint: { _id: 1 },\n session,\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\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getSession","transform","findVersions","collection","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","Model","versions","collectionConfig","payload","collections","config","session","options","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","flattenedFields","timestamps","query","adapter","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,uBAAuB,QAAQ,UAAS;AAI/E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAC,EAAEC,MAAM,EAAEC,IAAI,EAAEC,MAAMC,OAAO,EAAEC,KAAK,EAAE;IAE7F,MAAMC,QAAQ,IAAI,CAACC,QAAQ,CAACZ,WAAW;IACvC,MAAMa,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACf,WAAW,CAACgB,MAAM;IACpE,MAAMC,UAAU,MAAMpB,WAAW,IAAI,EAAEQ;IACvC,MAAMa,UAAwB;QAC5BjB;QACAgB;QACAV;IACF;IAEA,IAAIY,oBAAoB;IAExB,IAAIT,OAAO;QACT,MAAMU,cAAc3B,wBAAwBiB;QAC5CS,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIjB;IACJ,IAAI,CAACW,mBAAmB;QACtBX,OAAOb,eAAe;YACpBqB,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;YAC3BU,QAAQb,iBAAiBc,eAAe;YACxCzB;YACAM,MAAMC,WAAW;YACjBmB,YAAY;QACd;IAC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OG,IAAI;QACjBvB,QAAQlC,6BAA6B,IAAI,CAACsB,OAAO,CAACE,MAAM,EAAEH;QAC1DqC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
|
package/dist/init.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAA;AAgB9D,eAAO,MAAM,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAA6B,MAAM,SAAS,CAAA;AAgB9D,eAAO,MAAM,IAAI,EAAE,IA6FlB,CAAA"}
|
package/dist/init.js
CHANGED
|
@@ -5,7 +5,7 @@ import { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'
|
|
|
5
5
|
import { buildCollectionSchema } from './models/buildCollectionSchema.js';
|
|
6
6
|
import { buildGlobalModel } from './models/buildGlobalModel.js';
|
|
7
7
|
import { buildSchema } from './models/buildSchema.js';
|
|
8
|
-
import { getBuildQueryPlugin } from './queries/
|
|
8
|
+
import { getBuildQueryPlugin } from './queries/getBuildQueryPlugin.js';
|
|
9
9
|
import { getDBName } from './utilities/getDBName.js';
|
|
10
10
|
export const init = function init() {
|
|
11
11
|
this.payload.config.collections.forEach((collection)=>{
|
|
@@ -29,7 +29,6 @@ export const init = function init() {
|
|
|
29
29
|
...schemaOptions
|
|
30
30
|
},
|
|
31
31
|
configFields: versionCollectionFields,
|
|
32
|
-
parentIsLocalized: false,
|
|
33
32
|
payload: this.payload
|
|
34
33
|
});
|
|
35
34
|
versionSchema.plugin(paginate, {
|
|
@@ -69,7 +68,6 @@ export const init = function init() {
|
|
|
69
68
|
}
|
|
70
69
|
},
|
|
71
70
|
configFields: versionGlobalFields,
|
|
72
|
-
parentIsLocalized: false,
|
|
73
71
|
payload: this.payload
|
|
74
72
|
});
|
|
75
73
|
versionSchema.plugin(paginate, {
|
package/dist/init.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport mongoose from 'mongoose'\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'\nimport paginate from 'mongoose-paginate-v2'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport { buildCollectionSchema } from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport { buildSchema } from './models/buildSchema.js'\nimport { getBuildQueryPlugin } from './queries/
|
|
1
|
+
{"version":3,"sources":["../src/init.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Init, SanitizedCollectionConfig } from 'payload'\n\nimport mongoose from 'mongoose'\nimport mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2'\nimport paginate from 'mongoose-paginate-v2'\nimport { buildVersionCollectionFields, buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\nimport type { CollectionModel } from './types.js'\n\nimport { buildCollectionSchema } from './models/buildCollectionSchema.js'\nimport { buildGlobalModel } from './models/buildGlobalModel.js'\nimport { buildSchema } from './models/buildSchema.js'\nimport { getBuildQueryPlugin } from './queries/getBuildQueryPlugin.js'\nimport { getDBName } from './utilities/getDBName.js'\n\nexport const init: Init = function init(this: MongooseAdapter) {\n this.payload.config.collections.forEach((collection: SanitizedCollectionConfig) => {\n const schemaOptions = this.collectionsSchemaOptions[collection.slug]\n\n const schema = buildCollectionSchema(collection, this.payload, schemaOptions)\n\n if (collection.versions) {\n const versionModelName = getDBName({ config: collection, versions: true })\n\n const versionCollectionFields = buildVersionCollectionFields(this.payload.config, collection)\n\n const versionSchema = buildSchema({\n buildSchemaOptions: {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n ...schemaOptions,\n },\n configFields: versionCollectionFields,\n payload: this.payload,\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n collectionSlug: collection.slug,\n versionsFields: buildVersionCollectionFields(this.payload.config, collection, true),\n }),\n )\n\n if (Object.keys(collection.joins).length > 0) {\n versionSchema.plugin(mongooseAggregatePaginate)\n }\n\n const versionCollectionName =\n this.autoPluralization === true && !collection.dbName ? undefined : versionModelName\n\n this.versions[collection.slug] = mongoose.model(\n versionModelName,\n versionSchema,\n versionCollectionName,\n ) as CollectionModel\n }\n\n const modelName = getDBName({ config: collection })\n const collectionName =\n this.autoPluralization === true && !collection.dbName ? undefined : modelName\n\n this.collections[collection.slug] = mongoose.model(\n modelName,\n schema,\n collectionName,\n ) as CollectionModel\n })\n\n this.globals = buildGlobalModel(this.payload)\n\n this.payload.config.globals.forEach((global) => {\n if (global.versions) {\n const versionModelName = getDBName({ config: global, versions: true })\n\n const versionGlobalFields = buildVersionGlobalFields(this.payload.config, global)\n\n const versionSchema = buildSchema({\n buildSchemaOptions: {\n disableUnique: true,\n draftsEnabled: true,\n indexSortableFields: this.payload.config.indexSortableFields,\n options: {\n minimize: false,\n timestamps: false,\n },\n },\n configFields: versionGlobalFields,\n payload: this.payload,\n })\n\n versionSchema.plugin<any, PaginateOptions>(paginate, { useEstimatedCount: true }).plugin(\n getBuildQueryPlugin({\n versionsFields: buildVersionGlobalFields(this.payload.config, global, true),\n }),\n )\n\n this.versions[global.slug] = mongoose.model(\n versionModelName,\n versionSchema,\n versionModelName,\n ) as CollectionModel\n }\n })\n}\n"],"names":["mongoose","mongooseAggregatePaginate","paginate","buildVersionCollectionFields","buildVersionGlobalFields","buildCollectionSchema","buildGlobalModel","buildSchema","getBuildQueryPlugin","getDBName","init","payload","config","collections","forEach","collection","schemaOptions","collectionsSchemaOptions","slug","schema","versions","versionModelName","versionCollectionFields","versionSchema","buildSchemaOptions","disableUnique","draftsEnabled","indexSortableFields","options","minimize","timestamps","configFields","plugin","useEstimatedCount","collectionSlug","versionsFields","Object","keys","joins","length","versionCollectionName","autoPluralization","dbName","undefined","model","modelName","collectionName","globals","global","versionGlobalFields"],"mappings":"AAGA,OAAOA,cAAc,WAAU;AAC/B,OAAOC,+BAA+B,iCAAgC;AACtE,OAAOC,cAAc,uBAAsB;AAC3C,SAASC,4BAA4B,EAAEC,wBAAwB,QAAQ,UAAS;AAKhF,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,gBAAgB,QAAQ,+BAA8B;AAC/D,SAASC,WAAW,QAAQ,0BAAyB;AACrD,SAASC,mBAAmB,QAAQ,mCAAkC;AACtE,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,OAAa,SAASA;IACjC,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,WAAW,CAACC,OAAO,CAAC,CAACC;QACvC,MAAMC,gBAAgB,IAAI,CAACC,wBAAwB,CAACF,WAAWG,IAAI,CAAC;QAEpE,MAAMC,SAASd,sBAAsBU,YAAY,IAAI,CAACJ,OAAO,EAAEK;QAE/D,IAAID,WAAWK,QAAQ,EAAE;YACvB,MAAMC,mBAAmBZ,UAAU;gBAAEG,QAAQG;gBAAYK,UAAU;YAAK;YAExE,MAAME,0BAA0BnB,6BAA6B,IAAI,CAACQ,OAAO,CAACC,MAAM,EAAEG;YAElF,MAAMQ,gBAAgBhB,YAAY;gBAChCiB,oBAAoB;oBAClBC,eAAe;oBACfC,eAAe;oBACfC,qBAAqB,IAAI,CAAChB,OAAO,CAACC,MAAM,CAACe,mBAAmB;oBAC5DC,SAAS;wBACPC,UAAU;wBACVC,YAAY;oBACd;oBACA,GAAGd,aAAa;gBAClB;gBACAe,cAAcT;gBACdX,SAAS,IAAI,CAACA,OAAO;YACvB;YAEAY,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AAU;wBACVC,YAAY;oBACd;gBACF;gBACAC,cAAckB;gBACdtC,SAAS,IAAI,CAACA,OAAO;YACvB;YAEAY,cAAcS,MAAM,CAAuB9B,UAAU;gBAAE+B,mBAAmB;YAAK,GAAGD,MAAM,CACtFxB,oBAAoB;gBAClB2B,gBAAgB/B,yBAAyB,IAAI,CAACO,OAAO,CAACC,MAAM,EAAEoC,QAAQ;YACxE;YAGF,IAAI,CAAC5B,QAAQ,CAAC4B,OAAO9B,IAAI,CAAC,GAAGlB,SAAS4C,KAAK,CACzCvB,kBACAE,eACAF;QAEJ;IACF;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildCollectionSchema.d.ts","sourceRoot":"","sources":["../../src/models/buildCollectionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAQjE,eAAO,MAAM,qBAAqB,eACpB,yBAAyB,WAC5B,OAAO,yBAEf,
|
|
1
|
+
{"version":3,"file":"buildCollectionSchema.d.ts","sourceRoot":"","sources":["../../src/models/buildCollectionSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAQjE,eAAO,MAAM,qBAAqB,eACpB,yBAAyB,WAC5B,OAAO,yBAEf,MAyCF,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongooseAggregatePaginate from 'mongoose-aggregate-paginate-v2';
|
|
2
2
|
import paginate from 'mongoose-paginate-v2';
|
|
3
|
-
import { getBuildQueryPlugin } from '../queries/
|
|
3
|
+
import { getBuildQueryPlugin } from '../queries/getBuildQueryPlugin.js';
|
|
4
4
|
import { buildSchema } from './buildSchema.js';
|
|
5
5
|
export const buildCollectionSchema = (collection, payload, schemaOptions = {})=>{
|
|
6
6
|
const schema = buildSchema({
|
|
@@ -14,7 +14,6 @@ export const buildCollectionSchema = (collection, payload, schemaOptions = {})=>
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
configFields: collection.fields,
|
|
17
|
-
parentIsLocalized: false,
|
|
18
17
|
payload
|
|
19
18
|
});
|
|
20
19
|
if (Array.isArray(collection.upload.filenameCompoundIndex)) {
|
|
@@ -31,7 +30,7 @@ export const buildCollectionSchema = (collection, payload, schemaOptions = {})=>
|
|
|
31
30
|
}).plugin(getBuildQueryPlugin({
|
|
32
31
|
collectionSlug: collection.slug
|
|
33
32
|
}));
|
|
34
|
-
if (Object.keys(collection.joins).length > 0) {
|
|
33
|
+
if (Object.keys(collection.joins).length > 0 || Object.keys(collection.polymorphicJoins).length > 0) {
|
|
35
34
|
schema.plugin(mongooseAggregatePaginate);
|
|
36
35
|
}
|
|
37
36
|
return schema;
|