@payloadcms/db-mongodb 3.8.1-canary.84084b6 → 3.10.0
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 +20 -22
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts.map +1 -1
- package/dist/countGlobalVersions.js +20 -22
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.d.ts.map +1 -1
- package/dist/countVersions.js +20 -22
- package/dist/countVersions.js.map +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +23 -24
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +22 -20
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +36 -31
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +37 -32
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +7 -7
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +18 -14
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +7 -7
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +41 -74
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +20 -19
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +34 -63
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +33 -21
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +34 -62
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.d.ts.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +20 -16
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js.map +1 -1
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js +4 -4
- package/dist/predefinedMigrations/migrateVersionsV1_V2.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +3 -1
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +2 -1
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -0
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +2 -6
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/buildSearchParams.d.ts +3 -1
- package/dist/queries/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +15 -10
- package/dist/queries/buildSearchParams.js.map +1 -1
- package/dist/queries/buildSortParam.d.ts +1 -7
- 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 +3 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +2 -1
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +2 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +33 -6
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +42 -66
- package/dist/queryDrafts.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +27 -24
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +30 -28
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +30 -25
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +30 -27
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsert.d.ts.map +1 -1
- package/dist/upsert.js +1 -1
- package/dist/upsert.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 +13 -30
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.d.ts.map +1 -1
- package/dist/utilities/buildProjectionFromSelect.js +18 -1
- package/dist/utilities/buildProjectionFromSelect.js.map +1 -1
- package/dist/utilities/findMany.d.ts +20 -0
- package/dist/utilities/findMany.d.ts.map +1 -0
- package/dist/utilities/findMany.js +84 -0
- package/dist/utilities/findMany.js.map +1 -0
- package/dist/utilities/getHasNearConstraint.d.ts +3 -0
- package/dist/utilities/getHasNearConstraint.d.ts.map +1 -0
- package/dist/utilities/getHasNearConstraint.js +26 -0
- package/dist/utilities/getHasNearConstraint.js.map +1 -0
- package/dist/utilities/getSession.d.ts +9 -0
- package/dist/utilities/getSession.d.ts.map +1 -0
- package/dist/{withSession.js → utilities/getSession.js} +7 -6
- package/dist/utilities/getSession.js.map +1 -0
- package/dist/utilities/handleError.d.ts +3 -2
- package/dist/utilities/handleError.d.ts.map +1 -1
- package/dist/utilities/handleError.js +8 -7
- package/dist/utilities/handleError.js.map +1 -1
- package/dist/utilities/transform.d.ts +25 -0
- package/dist/utilities/transform.d.ts.map +1 -0
- package/dist/utilities/transform.js +254 -0
- package/dist/utilities/transform.js.map +1 -0
- package/dist/utilities/{sanitizeRelationshipIDs.spec.js → transform.spec.js} +23 -7
- package/dist/utilities/transform.spec.js.map +1 -0
- package/package.json +4 -4
- 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 -9
- package/dist/utilities/sanitizeRelationshipIDs.d.ts.map +0 -1
- package/dist/utilities/sanitizeRelationshipIDs.js +0 -125
- package/dist/utilities/sanitizeRelationshipIDs.js.map +0 -1
- package/dist/utilities/sanitizeRelationshipIDs.spec.js.map +0 -1
- package/dist/withSession.d.ts +0 -11
- package/dist/withSession.d.ts.map +0 -1
- package/dist/withSession.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import { buildVersionGlobalFields, type TypeWithID, type UpdateGlobalVersionArgs } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n options: optionsArgs = {},\n req,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const VersionModel = this.versions[globalSlug]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionGlobalFields(\n this.payload.config,\n this.payload.config.globals.find((global) => global.slug === globalSlug),\n true,\n )\n\n const session = await getSession(this, req)\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n session,\n where: whereToUse,\n })\n\n transform({\n adapter: this,\n data: versionData,\n fields,\n operation: 'update',\n timestamps: optionsArgs.timestamps !== false,\n })\n\n const doc: any = await VersionModel.collection.findOneAndUpdate(\n query,\n { $set: versionData },\n {\n ...optionsArgs,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n }),\n returnDocument: 'after',\n session,\n },\n )\n\n transform({\n adapter: this,\n data: doc,\n fields,\n operation: 'read',\n })\n\n return doc\n}\n"],"names":["buildVersionGlobalFields","buildProjectionFromSelect","getSession","transform","updateGlobalVersion","id","global","globalSlug","locale","options","optionsArgs","req","select","versionData","where","VersionModel","versions","whereToUse","equals","fields","payload","config","globals","find","slug","session","query","buildQuery","adapter","data","operation","timestamps","doc","collection","findOneAndUpdate","$set","projection","returnDocument"],"mappings":"AAAA,SAASA,wBAAwB,QAAuD,UAAS;AAIjG,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,QAAQC,UAAU,EAClBC,MAAM,EACNC,SAASC,cAAc,CAAC,CAAC,EACzBC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACT,WAAW;IAC9C,MAAMU,aAAaH,SAAS;QAAET,IAAI;YAAEa,QAAQb;QAAG;IAAE;IACjD,MAAMc,SAASnB,yBACb,IAAI,CAACoB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACC,MAAM,CAACC,OAAO,CAACC,IAAI,CAAC,CAACjB,SAAWA,OAAOkB,IAAI,KAAKjB,aAC7D;IAGF,MAAMkB,UAAU,MAAMvB,WAAW,IAAI,EAAES;IAEvC,MAAMe,QAAQ,MAAMX,aAAaY,UAAU,CAAC;QAC1CnB;QACAY,SAAS,IAAI,CAACA,OAAO;QACrBK;QACAX,OAAOG;IACT;IAEAd,UAAU;QACRyB,SAAS,IAAI;QACbC,MAAMhB;QACNM;QACAW,WAAW;QACXC,YAAYrB,YAAYqB,UAAU,KAAK;IACzC;IAEA,MAAMC,MAAW,MAAMjB,aAAakB,UAAU,CAACC,gBAAgB,CAC7DR,OACA;QAAES,MAAMtB;IAAY,GACpB;QACE,GAAGH,WAAW;QACd0B,YAAYnC,0BAA0B;YACpC2B,SAAS,IAAI;YACbT;YACAP;QACF;QACAyB,gBAAgB;QAChBZ;IACF;IAGFtB,UAAU;QACRyB,SAAS,IAAI;QACbC,MAAMG;QACNb;QACAW,WAAW;IACb;IAEA,OAAOE;AACT"}
|
package/dist/updateOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AASxC,eAAO,MAAM,SAAS,EAAE,SA+CvB,CAAA"}
|
package/dist/updateOne.js
CHANGED
|
@@ -1,40 +1,49 @@
|
|
|
1
1
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
2
|
+
import { getSession } from './utilities/getSession.js';
|
|
2
3
|
import { handleError } from './utilities/handleError.js';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { withSession } from './withSession.js';
|
|
6
|
-
export const updateOne = async function updateOne({ id, collection, data, locale, options: optionsArgs = {}, req = {}, select, where: whereArg }) {
|
|
4
|
+
import { transform } from './utilities/transform.js';
|
|
5
|
+
export const updateOne = async function updateOne({ id, collection, data, locale, options: optionsArgs = {}, req, select, where: whereArg }) {
|
|
7
6
|
const where = id ? {
|
|
8
7
|
id: {
|
|
9
8
|
equals: id
|
|
10
9
|
}
|
|
11
10
|
} : whereArg;
|
|
12
11
|
const Model = this.collections[collection];
|
|
13
|
-
const fields = this.payload.collections[collection].config.
|
|
14
|
-
const
|
|
15
|
-
...optionsArgs,
|
|
16
|
-
...await withSession(this, req),
|
|
17
|
-
lean: true,
|
|
18
|
-
new: true,
|
|
19
|
-
projection: buildProjectionFromSelect({
|
|
20
|
-
adapter: this,
|
|
21
|
-
fields: this.payload.collections[collection].config.flattenedFields,
|
|
22
|
-
select
|
|
23
|
-
})
|
|
24
|
-
};
|
|
12
|
+
const fields = this.payload.collections[collection].config.flattenedFields;
|
|
13
|
+
const session = await getSession(this, req);
|
|
25
14
|
const query = await Model.buildQuery({
|
|
26
15
|
locale,
|
|
27
16
|
payload: this.payload,
|
|
17
|
+
session,
|
|
28
18
|
where
|
|
29
19
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
config: this.payload.config,
|
|
20
|
+
transform({
|
|
21
|
+
adapter: this,
|
|
33
22
|
data,
|
|
34
|
-
fields
|
|
23
|
+
fields,
|
|
24
|
+
operation: 'update',
|
|
25
|
+
timestamps: optionsArgs.timestamps !== false
|
|
35
26
|
});
|
|
36
27
|
try {
|
|
37
|
-
result = await Model.findOneAndUpdate(query,
|
|
28
|
+
const result = await Model.collection.findOneAndUpdate(query, {
|
|
29
|
+
$set: data
|
|
30
|
+
}, {
|
|
31
|
+
...optionsArgs,
|
|
32
|
+
projection: buildProjectionFromSelect({
|
|
33
|
+
adapter: this,
|
|
34
|
+
fields,
|
|
35
|
+
select
|
|
36
|
+
}),
|
|
37
|
+
returnDocument: 'after',
|
|
38
|
+
session
|
|
39
|
+
});
|
|
40
|
+
transform({
|
|
41
|
+
adapter: this,
|
|
42
|
+
data: result,
|
|
43
|
+
fields,
|
|
44
|
+
operation: 'read'
|
|
45
|
+
});
|
|
46
|
+
return result;
|
|
38
47
|
} catch (error) {
|
|
39
48
|
handleError({
|
|
40
49
|
collection,
|
|
@@ -42,10 +51,6 @@ export const updateOne = async function updateOne({ id, collection, data, locale
|
|
|
42
51
|
req
|
|
43
52
|
});
|
|
44
53
|
}
|
|
45
|
-
result = JSON.parse(JSON.stringify(result));
|
|
46
|
-
result.id = result._id;
|
|
47
|
-
result = sanitizeInternalFields(result);
|
|
48
|
-
return result;
|
|
49
54
|
};
|
|
50
55
|
|
|
51
56
|
//# sourceMappingURL=updateOne.js.map
|
package/dist/updateOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { UpdateOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: MongooseAdapter,\n { id, collection, data, locale, options: optionsArgs = {}, req, select, where: whereArg },\n) {\n const where = id ? { id: { equals: id } } : whereArg\n const Model = this.collections[collection]\n const fields = this.payload.collections[collection].config.flattenedFields\n\n const session = await getSession(this, req)\n\n const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n session,\n where,\n })\n\n transform({\n adapter: this,\n data,\n fields,\n operation: 'update',\n timestamps: optionsArgs.timestamps !== false,\n })\n\n try {\n const result = await Model.collection.findOneAndUpdate(\n query,\n { $set: data },\n {\n ...optionsArgs,\n projection: buildProjectionFromSelect({ adapter: this, fields, select }),\n returnDocument: 'after',\n session,\n },\n )\n\n transform({\n adapter: this,\n data: result,\n fields,\n operation: 'read',\n })\n return result\n } catch (error) {\n handleError({ collection, error, req })\n }\n}\n"],"names":["buildProjectionFromSelect","getSession","handleError","transform","updateOne","id","collection","data","locale","options","optionsArgs","req","select","where","whereArg","equals","Model","collections","fields","payload","config","flattenedFields","session","query","buildQuery","adapter","operation","timestamps","result","findOneAndUpdate","$set","projection","returnDocument","error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ersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ1E,eAAO,MAAM,aAAa,EAAE,aAwD3B,CAAA"}
|
package/dist/updateVersion.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
1
|
import { buildVersionCollectionFields } from 'payload';
|
|
2
2
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export const updateVersion = async function updateVersion({ id, collection, locale, options: optionsArgs = {}, req
|
|
3
|
+
import { getSession } from './utilities/getSession.js';
|
|
4
|
+
import { transform } from './utilities/transform.js';
|
|
5
|
+
export const updateVersion = async function updateVersion({ id, collection, locale, options: optionsArgs = {}, req, select, versionData, where }) {
|
|
6
6
|
const VersionModel = this.versions[collection];
|
|
7
7
|
const whereToUse = where || {
|
|
8
8
|
id: {
|
|
9
9
|
equals: id
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
const fields = buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config);
|
|
13
|
-
const
|
|
14
|
-
...optionsArgs,
|
|
15
|
-
...await withSession(this, req),
|
|
16
|
-
lean: true,
|
|
17
|
-
new: true,
|
|
18
|
-
projection: buildProjectionFromSelect({
|
|
19
|
-
adapter: this,
|
|
20
|
-
fields: buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config, true),
|
|
21
|
-
select
|
|
22
|
-
})
|
|
23
|
-
};
|
|
12
|
+
const fields = buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config, true);
|
|
13
|
+
const session = await getSession(this, req);
|
|
24
14
|
const query = await VersionModel.buildQuery({
|
|
25
15
|
locale,
|
|
26
16
|
payload: this.payload,
|
|
17
|
+
session,
|
|
27
18
|
where: whereToUse
|
|
28
19
|
});
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
transform({
|
|
21
|
+
adapter: this,
|
|
31
22
|
data: versionData,
|
|
32
|
-
fields
|
|
23
|
+
fields,
|
|
24
|
+
operation: 'update',
|
|
25
|
+
timestamps: optionsArgs.timestamps !== false
|
|
26
|
+
});
|
|
27
|
+
const doc = await VersionModel.collection.findOneAndUpdate(query, {
|
|
28
|
+
$set: versionData
|
|
29
|
+
}, {
|
|
30
|
+
...optionsArgs,
|
|
31
|
+
projection: buildProjectionFromSelect({
|
|
32
|
+
adapter: this,
|
|
33
|
+
fields: buildVersionCollectionFields(this.payload.config, this.payload.collections[collection].config, true),
|
|
34
|
+
select
|
|
35
|
+
}),
|
|
36
|
+
returnDocument: 'after',
|
|
37
|
+
session
|
|
38
|
+
});
|
|
39
|
+
transform({
|
|
40
|
+
adapter: this,
|
|
41
|
+
data: doc,
|
|
42
|
+
fields,
|
|
43
|
+
operation: 'read'
|
|
33
44
|
});
|
|
34
|
-
|
|
35
|
-
const result = JSON.parse(JSON.stringify(doc));
|
|
36
|
-
const verificationToken = doc._verificationToken;
|
|
37
|
-
// custom id type reset
|
|
38
|
-
result.id = result._id;
|
|
39
|
-
if (verificationToken) {
|
|
40
|
-
result._verificationToken = verificationToken;
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
45
|
+
return doc;
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
//# sourceMappingURL=updateVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import { buildVersionCollectionFields, type UpdateVersion } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateVersion: UpdateVersion = async function updateVersion(\n this: MongooseAdapter,\n { id, collection, locale, options: optionsArgs = {}, req, select, versionData, where },\n) {\n const VersionModel = this.versions[collection]\n const whereToUse = where || { id: { equals: id } }\n const fields = buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\n true,\n )\n\n const session = await getSession(this, req)\n\n const query = await VersionModel.buildQuery({\n locale,\n payload: this.payload,\n session,\n where: whereToUse,\n })\n\n transform({\n adapter: this,\n data: versionData,\n fields,\n operation: 'update',\n timestamps: optionsArgs.timestamps !== false,\n })\n\n const doc = await VersionModel.collection.findOneAndUpdate(\n query,\n { $set: versionData },\n {\n ...optionsArgs,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collection].config,\n true,\n ),\n select,\n }),\n returnDocument: 'after',\n session,\n },\n )\n\n transform({\n adapter: this,\n data: doc,\n fields,\n operation: 'read',\n })\n\n return doc as any\n}\n"],"names":["buildVersionCollectionFields","buildProjectionFromSelect","getSession","transform","updateVersion","id","collection","locale","options","optionsArgs","req","select","versionData","where","VersionModel","versions","whereToUse","equals","fields","payload","config","collections","session","query","buildQuery","adapter","data","operation","timestamps","doc","findOneAndUpdate","$set","projection","returnDocument"],"mappings":"AAAA,SAASA,4BAA4B,QAA4B,UAAS;AAI1E,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,UAAU,EAAEC,MAAM,EAAEC,SAASC,cAAc,CAAC,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAE;IAEtF,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACT,WAAW;IAC9C,MAAMU,aAAaH,SAAS;QAAER,IAAI;YAAEY,QAAQZ;QAAG;IAAE;IACjD,MAAMa,SAASlB,6BACb,IAAI,CAACmB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACE,WAAW,CAACf,WAAW,CAACc,MAAM,EAC3C;IAGF,MAAME,UAAU,MAAMpB,WAAW,IAAI,EAAEQ;IAEvC,MAAMa,QAAQ,MAAMT,aAAaU,UAAU,CAAC;QAC1CjB;QACAY,SAAS,IAAI,CAACA,OAAO;QACrBG;QACAT,OAAOG;IACT;IAEAb,UAAU;QACRsB,SAAS,IAAI;QACbC,MAAMd;QACNM;QACAS,WAAW;QACXC,YAAYnB,YAAYmB,UAAU,KAAK;IACzC;IAEA,MAAMC,MAAM,MAAMf,aAAaR,UAAU,CAACwB,gBAAgB,CACxDP,OACA;QAAEQ,MAAMnB;IAAY,GACpB;QACE,GAAGH,WAAW;QACduB,YAAY/B,0BAA0B;YACpCwB,SAAS,IAAI;YACbP,QAAQlB,6BACN,IAAI,CAACmB,OAAO,CAACC,MAAM,EACnB,IAAI,CAACD,OAAO,CAACE,WAAW,CAACf,WAAW,CAACc,MAAM,EAC3C;YAEFT;QACF;QACAsB,gBAAgB;QAChBX;IACF;IAGFnB,UAAU;QACRsB,SAAS,IAAI;QACbC,MAAMG;QACNX;QACAS,WAAW;IACb;IAEA,OAAOE;AACT,EAAC"}
|
package/dist/upsert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../src/upsert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../src/upsert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAIrC,eAAO,MAAM,MAAM,EAAE,MAKpB,CAAA"}
|
package/dist/upsert.js
CHANGED
package/dist/upsert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/upsert.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../src/upsert.ts"],"sourcesContent":["import type { Upsert } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const upsert: Upsert = async function upsert(\n this: MongooseAdapter,\n { collection, data, locale, req, select, where },\n) {\n return this.updateOne({ collection, data, locale, options: { upsert: true }, req, select, where })\n}\n"],"names":["upsert","collection","data","locale","req","select","where","updateOne","options"],"mappings":"AAIA,OAAO,MAAMA,SAAiB,eAAeA,OAE3C,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAEhD,OAAO,IAAI,CAACC,SAAS,CAAC;QAAEN;QAAYC;QAAMC;QAAQK,SAAS;YAAER,QAAQ;QAAK;QAAGI;QAAKC;QAAQC;IAAM;AAClG,EAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import type { ClientSession } from 'mongodb';
|
|
1
2
|
import type { PipelineStage } from 'mongoose';
|
|
2
|
-
import type { CollectionSlug, JoinQuery, SanitizedCollectionConfig
|
|
3
|
+
import type { CollectionSlug, JoinQuery, SanitizedCollectionConfig } from 'payload';
|
|
3
4
|
import type { MongooseAdapter } from '../index.js';
|
|
4
5
|
type BuildJoinAggregationArgs = {
|
|
5
6
|
adapter: MongooseAdapter;
|
|
6
7
|
collection: CollectionSlug;
|
|
7
8
|
collectionConfig: SanitizedCollectionConfig;
|
|
8
9
|
joins: JoinQuery;
|
|
9
|
-
limit?: number;
|
|
10
10
|
locale: string;
|
|
11
11
|
projection?: Record<string, true>;
|
|
12
|
-
|
|
12
|
+
session?: ClientSession;
|
|
13
13
|
/** whether the query is from drafts */
|
|
14
14
|
versions?: boolean;
|
|
15
15
|
};
|
|
16
|
-
export declare const buildJoinAggregation: ({ adapter, collection, collectionConfig, joins,
|
|
16
|
+
export declare const buildJoinAggregation: ({ adapter, collection, collectionConfig, joins, locale, projection, session, versions, }: BuildJoinAggregationArgs) => Promise<PipelineStage[] | undefined>;
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=buildJoinAggregation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildJoinAggregation.d.ts","sourceRoot":"","sources":["../../src/utilities/buildJoinAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,yBAAyB,
|
|
1
|
+
{"version":3,"file":"buildJoinAggregation.d.ts","sourceRoot":"","sources":["../../src/utilities/buildJoinAggregation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,yBAAyB,EAAS,MAAM,SAAS,CAAA;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,wBAAwB,GAAG;IAC9B,OAAO,EAAE,eAAe,CAAA;IACxB,UAAU,EAAE,cAAc,CAAA;IAC1B,gBAAgB,EAAE,yBAAyB,CAAA;IAC3C,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACjC,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,uCAAuC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,oBAAoB,6FAS9B,wBAAwB,KAAG,OAAO,CAAC,aAAa,EAAE,GAAG,SAAS,CAmJhE,CAAA"}
|
|
@@ -1,26 +1,10 @@
|
|
|
1
1
|
import { buildSortParam } from '../queries/buildSortParam.js';
|
|
2
|
-
export const buildJoinAggregation = async ({ adapter, collection, collectionConfig, joins,
|
|
2
|
+
export const buildJoinAggregation = async ({ adapter, collection, collectionConfig, joins, locale, projection, session, versions })=>{
|
|
3
3
|
if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {
|
|
4
4
|
return;
|
|
5
5
|
}
|
|
6
6
|
const joinConfig = adapter.payload.collections[collection].config.joins;
|
|
7
|
-
const aggregate = [
|
|
8
|
-
{
|
|
9
|
-
$sort: {
|
|
10
|
-
createdAt: -1
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
];
|
|
14
|
-
if (query) {
|
|
15
|
-
aggregate.push({
|
|
16
|
-
$match: query
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
if (limit) {
|
|
20
|
-
aggregate.push({
|
|
21
|
-
$limit: limit
|
|
22
|
-
});
|
|
23
|
-
}
|
|
7
|
+
const aggregate = [];
|
|
24
8
|
for (const slug of Object.keys(joinConfig)){
|
|
25
9
|
for (const join of joinConfig[slug]){
|
|
26
10
|
const joinModel = adapter.collections[join.field.collection];
|
|
@@ -31,18 +15,17 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
31
15
|
continue;
|
|
32
16
|
}
|
|
33
17
|
const { limit: limitJoin = join.field.defaultLimit ?? 10, sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort, where: whereJoin } = joins?.[join.joinPath] || {};
|
|
34
|
-
const sort = buildSortParam({
|
|
18
|
+
const $sort = buildSortParam({
|
|
35
19
|
config: adapter.payload.config,
|
|
36
20
|
fields: adapter.payload.collections[slug].config.flattenedFields,
|
|
37
21
|
locale,
|
|
38
22
|
sort: sortJoin,
|
|
39
23
|
timestamps: true
|
|
40
24
|
});
|
|
41
|
-
const sortProperty = Object.keys(sort)[0];
|
|
42
|
-
const sortDirection = sort[sortProperty] === 'asc' ? 1 : -1;
|
|
43
25
|
const $match = await joinModel.buildQuery({
|
|
44
26
|
locale,
|
|
45
27
|
payload: adapter.payload,
|
|
28
|
+
session,
|
|
46
29
|
where: whereJoin
|
|
47
30
|
});
|
|
48
31
|
const pipeline = [
|
|
@@ -50,9 +33,7 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
50
33
|
$match
|
|
51
34
|
},
|
|
52
35
|
{
|
|
53
|
-
$sort
|
|
54
|
-
[sortProperty]: sortDirection
|
|
55
|
-
}
|
|
36
|
+
$sort
|
|
56
37
|
}
|
|
57
38
|
];
|
|
58
39
|
if (limitJoin > 0) {
|
|
@@ -60,13 +41,17 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
60
41
|
$limit: limitJoin + 1
|
|
61
42
|
});
|
|
62
43
|
}
|
|
44
|
+
let polymorphicSuffix = '';
|
|
45
|
+
if (Array.isArray(join.targetField.relationTo)) {
|
|
46
|
+
polymorphicSuffix = '.value';
|
|
47
|
+
}
|
|
63
48
|
if (adapter.payload.config.localization && locale === 'all') {
|
|
64
49
|
adapter.payload.config.localization.localeCodes.forEach((code)=>{
|
|
65
50
|
const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${code}`;
|
|
66
51
|
aggregate.push({
|
|
67
52
|
$lookup: {
|
|
68
53
|
as: `${as}.docs`,
|
|
69
|
-
foreignField: `${join.field.on}${code}`,
|
|
54
|
+
foreignField: `${join.field.on}${code}${polymorphicSuffix}`,
|
|
70
55
|
from: adapter.collections[slug].collection.name,
|
|
71
56
|
localField: versions ? 'parent' : '_id',
|
|
72
57
|
pipeline
|
|
@@ -109,7 +94,7 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
109
94
|
aggregate.push({
|
|
110
95
|
$lookup: {
|
|
111
96
|
as: `${as}.docs`,
|
|
112
|
-
foreignField: `${join.field.on}${localeSuffix}`,
|
|
97
|
+
foreignField: `${join.field.on}${localeSuffix}${polymorphicSuffix}`,
|
|
113
98
|
from: adapter.collections[slug].collection.name,
|
|
114
99
|
localField: versions ? 'parent' : '_id',
|
|
115
100
|
pipeline
|
|
@@ -148,10 +133,8 @@ export const buildJoinAggregation = async ({ adapter, collection, collectionConf
|
|
|
148
133
|
}
|
|
149
134
|
}
|
|
150
135
|
}
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
$project: projection
|
|
154
|
-
});
|
|
136
|
+
if (!aggregate.length) {
|
|
137
|
+
return;
|
|
155
138
|
}
|
|
156
139
|
return aggregate;
|
|
157
140
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildJoinAggregation.ts"],"sourcesContent":["import type { PipelineStage } from 'mongoose'\nimport type { CollectionSlug, JoinQuery, SanitizedCollectionConfig, Where } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { buildSortParam } from '../queries/buildSortParam.js'\n\ntype BuildJoinAggregationArgs = {\n adapter: MongooseAdapter\n collection: CollectionSlug\n collectionConfig: SanitizedCollectionConfig\n joins: JoinQuery\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildJoinAggregation.ts"],"sourcesContent":["import type { ClientSession } from 'mongodb'\nimport type { PipelineStage } from 'mongoose'\nimport type { CollectionSlug, JoinQuery, SanitizedCollectionConfig, Where } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nimport { buildSortParam } from '../queries/buildSortParam.js'\n\ntype BuildJoinAggregationArgs = {\n adapter: MongooseAdapter\n collection: CollectionSlug\n collectionConfig: SanitizedCollectionConfig\n joins: JoinQuery\n locale: string\n projection?: Record<string, true>\n session?: ClientSession\n /** whether the query is from drafts */\n versions?: boolean\n}\n\nexport const buildJoinAggregation = async ({\n adapter,\n collection,\n collectionConfig,\n joins,\n locale,\n projection,\n session,\n versions,\n}: BuildJoinAggregationArgs): Promise<PipelineStage[] | undefined> => {\n if (Object.keys(collectionConfig.joins).length === 0 || joins === false) {\n return\n }\n\n const joinConfig = adapter.payload.collections[collection].config.joins\n const aggregate: PipelineStage[] = []\n\n for (const slug of Object.keys(joinConfig)) {\n for (const join of joinConfig[slug]) {\n const joinModel = adapter.collections[join.field.collection]\n\n if (projection && !projection[join.joinPath]) {\n continue\n }\n\n if (joins?.[join.joinPath] === false) {\n continue\n }\n\n const {\n limit: limitJoin = join.field.defaultLimit ?? 10,\n sort: sortJoin = join.field.defaultSort || collectionConfig.defaultSort,\n where: whereJoin,\n } = joins?.[join.joinPath] || {}\n\n const $sort = buildSortParam({\n config: adapter.payload.config,\n fields: adapter.payload.collections[slug].config.flattenedFields,\n locale,\n sort: sortJoin,\n timestamps: true,\n })\n\n const $match = await joinModel.buildQuery({\n locale,\n payload: adapter.payload,\n session,\n where: whereJoin,\n })\n\n const pipeline: Exclude<PipelineStage, PipelineStage.Merge | PipelineStage.Out>[] = [\n { $match },\n {\n $sort,\n },\n ]\n\n if (limitJoin > 0) {\n pipeline.push({\n $limit: limitJoin + 1,\n })\n }\n\n let polymorphicSuffix = ''\n if (Array.isArray(join.targetField.relationTo)) {\n polymorphicSuffix = '.value'\n }\n\n if (adapter.payload.config.localization && locale === 'all') {\n adapter.payload.config.localization.localeCodes.forEach((code) => {\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${code}`\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField: `${join.field.on}${code}${polymorphicSuffix}`,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: limitJoin\n ? { $gt: [{ $size: `$${as}.docs` }, limitJoin] }\n : false,\n // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n })\n } else {\n const localeSuffix =\n join.field.localized && adapter.payload.config.localization && locale ? `.${locale}` : ''\n const as = `${versions ? `version.${join.joinPath}` : join.joinPath}${localeSuffix}`\n\n aggregate.push(\n {\n $lookup: {\n as: `${as}.docs`,\n foreignField: `${join.field.on}${localeSuffix}${polymorphicSuffix}`,\n from: adapter.collections[slug].collection.name,\n localField: versions ? 'parent' : '_id',\n pipeline,\n },\n },\n {\n $addFields: {\n [`${as}.docs`]: {\n $map: {\n as: 'doc',\n in: '$$doc._id',\n input: `$${as}.docs`,\n },\n }, // Slicing the docs to match the limit\n [`${as}.hasNextPage`]: {\n $gt: [{ $size: `$${as}.docs` }, limitJoin || Number.MAX_VALUE],\n }, // Boolean indicating if more docs than limit\n },\n },\n )\n if (limitJoin > 0) {\n aggregate.push({\n $addFields: {\n [`${as}.docs`]: {\n $slice: [`$${as}.docs`, limitJoin],\n },\n },\n })\n }\n }\n }\n }\n\n if (!aggregate.length) {\n return\n }\n\n return aggregate\n}\n"],"names":["buildSortParam","buildJoinAggregation","adapter","collection","collectionConfig","joins","locale","projection","session","versions","Object","keys","length","joinConfig","payload","collections","config","aggregate","slug","join","joinModel","field","joinPath","limit","limitJoin","defaultLimit","sort","sortJoin","defaultSort","where","whereJoin","$sort","fields","flattenedFields","timestamps","$match","buildQuery","pipeline","push","$limit","polymorphicSuffix","Array","isArray","targetField","relationTo","localization","localeCodes","forEach","code","as","$lookup","foreignField","on","from","name","localField","$addFields","$map","in","input","$gt","$size","$slice","localeSuffix","localized","Number","MAX_VALUE"],"mappings":"AAMA,SAASA,cAAc,QAAQ,+BAA8B;AAc7D,OAAO,MAAMC,uBAAuB,OAAO,EACzCC,OAAO,EACPC,UAAU,EACVC,gBAAgB,EAChBC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,QAAQ,EACiB;IACzB,IAAIC,OAAOC,IAAI,CAACP,iBAAiBC,KAAK,EAAEO,MAAM,KAAK,KAAKP,UAAU,OAAO;QACvE;IACF;IAEA,MAAMQ,aAAaX,QAAQY,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM,CAACX,KAAK;IACvE,MAAMY,YAA6B,EAAE;IAErC,KAAK,MAAMC,QAAQR,OAAOC,IAAI,CAACE,YAAa;QAC1C,KAAK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gBAEpF9C,UAAUqB,IAAI,CACZ;oBACEY,SAAS;wBACPD,IAAI,GAAGA,GAAG,KAAK,CAAC;wBAChBE,cAAc,GAAGhC,KAAKE,KAAK,CAAC+B,EAAE,GAAGW,eAAevB,mBAAmB;wBACnEa,MAAMnD,QAAQa,WAAW,CAACG,KAAK,CAACf,UAAU,CAACmD,IAAI;wBAC/CC,YAAY9C,WAAW,WAAW;wBAClC4B;oBACF;gBACF,GACA;oBACEmB,YAAY;wBACV,CAAC,GAAGP,GAAG,KAAK,CAAC,CAAC,EAAE;4BACdQ,MAAM;gCACJR,IAAI;gCACJS,IAAI;gCACJC,OAAO,CAAC,CAAC,EAAEV,GAAG,KAAK,CAAC;4BACtB;wBACF;wBACA,CAAC,GAAGA,GAAG,YAAY,CAAC,CAAC,EAAE;4BACrBW,KAAK;gCAAC;oCAAEC,OAAO,CAAC,CAAC,EAAEZ,GAAG,KAAK,CAAC;gCAAC;gCAAGzB,aAAayC,OAAOC,SAAS;6BAAC;wBAChE;oBACF;gBACF;gBAEF,IAAI1C,YAAY,GAAG;oBACjBP,UAAUqB,IAAI,CAAC;wBACbkB,YAAY;4BACV,CAAC,GAAGP,GAAG,KAAK,CAAC,CAAC,EAAE;gCACda,QAAQ;oCAAC,CAAC,CAAC,EAAEb,GAAG,KAAK,CAAC;oCAAEzB;iCAAU;4BACpC;wBACF;oBACF;gBACF;YACF;QACF;IACF;IAEA,IAAI,CAACP,UAAUL,MAAM,EAAE;QACrB;IACF;IAEA,OAAOK;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildProjectionFromSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/buildProjectionFromSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"buildProjectionFromSelect.d.ts","sourceRoot":"","sources":["../../src/utilities/buildProjectionFromSelect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,cAAc,EAAc,UAAU,EAAE,MAAM,SAAS,CAAA;AAIhG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAiMlD,eAAO,MAAM,yBAAyB,iCAInC;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,KAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,SAmB1B,CAAA"}
|
|
@@ -10,6 +10,10 @@ const addFieldToProjection = ({ adapter, databaseSchemaPath, field, projection,
|
|
|
10
10
|
projection[`${databaseSchemaPath}${field.name}`] = true;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
const blockTypeField = {
|
|
14
|
+
name: 'blockType',
|
|
15
|
+
type: 'text'
|
|
16
|
+
};
|
|
13
17
|
const traverseFields = ({ adapter, databaseSchemaPath = '', fields, projection, select, selectAllOnCurrentLevel = false, selectMode, withinLocalizedField = false })=>{
|
|
14
18
|
for (const field of fields){
|
|
15
19
|
if (fieldAffectsData(field)) {
|
|
@@ -78,6 +82,13 @@ const traverseFields = ({ adapter, databaseSchemaPath = '', fields, projection,
|
|
|
78
82
|
const blocksSelect = select[field.name];
|
|
79
83
|
for (const block of field.blocks){
|
|
80
84
|
if (selectMode === 'include' && blocksSelect[block.slug] === true || selectMode === 'exclude' && typeof blocksSelect[block.slug] === 'undefined') {
|
|
85
|
+
addFieldToProjection({
|
|
86
|
+
adapter,
|
|
87
|
+
databaseSchemaPath: fieldDatabaseSchemaPath,
|
|
88
|
+
field: blockTypeField,
|
|
89
|
+
projection,
|
|
90
|
+
withinLocalizedField: fieldWithinLocalizedField
|
|
91
|
+
});
|
|
81
92
|
traverseFields({
|
|
82
93
|
adapter,
|
|
83
94
|
databaseSchemaPath: fieldDatabaseSchemaPath,
|
|
@@ -99,7 +110,13 @@ const traverseFields = ({ adapter, databaseSchemaPath = '', fields, projection,
|
|
|
99
110
|
}
|
|
100
111
|
if (blockSelectMode === 'include') {
|
|
101
112
|
blocksSelect[block.slug]['id'] = true;
|
|
102
|
-
|
|
113
|
+
addFieldToProjection({
|
|
114
|
+
adapter,
|
|
115
|
+
databaseSchemaPath: fieldDatabaseSchemaPath,
|
|
116
|
+
field: blockTypeField,
|
|
117
|
+
projection,
|
|
118
|
+
withinLocalizedField: fieldWithinLocalizedField
|
|
119
|
+
});
|
|
103
120
|
}
|
|
104
121
|
traverseFields({
|
|
105
122
|
adapter,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/buildProjectionFromSelect.ts"],"sourcesContent":["import type { FieldAffectingData, FlattenedField, SelectMode, SelectType } from 'payload'\n\nimport { deepCopyObjectSimple, fieldAffectsData, getSelectMode } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nconst addFieldToProjection = ({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n}: {\n adapter: MongooseAdapter\n databaseSchemaPath: string\n field: FieldAffectingData\n projection: Record<string, true>\n withinLocalizedField: boolean\n}) => {\n const { config } = adapter.payload\n\n if (withinLocalizedField && config.localization) {\n for (const locale of config.localization.localeCodes) {\n const localeDatabaseSchemaPath = databaseSchemaPath.replace('<locale>', locale)\n projection[`${localeDatabaseSchemaPath}${field.name}`] = true\n }\n } else {\n projection[`${databaseSchemaPath}${field.name}`] = true\n }\n}\n\nconst traverseFields = ({\n adapter,\n databaseSchemaPath = '',\n fields,\n projection,\n select,\n selectAllOnCurrentLevel = false,\n selectMode,\n withinLocalizedField = false,\n}: {\n adapter: MongooseAdapter\n databaseSchemaPath?: string\n fields: FlattenedField[]\n projection: Record<string, true>\n select: SelectType\n selectAllOnCurrentLevel?: boolean\n selectMode: SelectMode\n withinLocalizedField?: boolean\n}) => {\n for (const field of fields) {\n if (fieldAffectsData(field)) {\n if (selectMode === 'include') {\n if (select[field.name] === true || selectAllOnCurrentLevel) {\n addFieldToProjection({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n })\n continue\n }\n\n if (!select[field.name]) {\n continue\n }\n }\n\n if (selectMode === 'exclude') {\n if (typeof select[field.name] === 'undefined') {\n addFieldToProjection({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n })\n continue\n }\n\n if (select[field.name] === false) {\n continue\n }\n }\n }\n\n let fieldDatabaseSchemaPath = databaseSchemaPath\n let fieldWithinLocalizedField = withinLocalizedField\n\n if (fieldAffectsData(field)) {\n fieldDatabaseSchemaPath = `${databaseSchemaPath}${field.name}.`\n\n if (field.localized) {\n fieldDatabaseSchemaPath = `${fieldDatabaseSchemaPath}<locale>.`\n fieldWithinLocalizedField = true\n }\n }\n\n switch (field.type) {\n case 'array':\n case 'group':\n case 'tab': {\n const fieldSelect = select[field.name] as SelectType\n\n if (field.type === 'array' && selectMode === 'include') {\n fieldSelect['id'] = true\n }\n\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: field.flattenedFields,\n projection,\n select: fieldSelect,\n selectMode,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n\n break\n }\n\n case 'blocks': {\n const blocksSelect = select[field.name] as SelectType\n\n for (const block of field.blocks) {\n if (\n (selectMode === 'include' && blocksSelect[block.slug] === true) ||\n (selectMode === 'exclude' && typeof blocksSelect[block.slug] === 'undefined')\n ) {\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: block.flattenedFields,\n projection,\n select: {},\n selectAllOnCurrentLevel: true,\n selectMode: 'include',\n withinLocalizedField: fieldWithinLocalizedField,\n })\n continue\n }\n\n let blockSelectMode = selectMode\n\n if (selectMode === 'exclude' && blocksSelect[block.slug] === false) {\n blockSelectMode = 'include'\n }\n\n if (typeof blocksSelect[block.slug] !== 'object') {\n blocksSelect[block.slug] = {}\n }\n\n if (blockSelectMode === 'include') {\n blocksSelect[block.slug]['id'] = true\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/buildProjectionFromSelect.ts"],"sourcesContent":["import type { Field, FieldAffectingData, FlattenedField, SelectMode, SelectType } from 'payload'\n\nimport { deepCopyObjectSimple, fieldAffectsData, getSelectMode } from 'payload/shared'\n\nimport type { MongooseAdapter } from '../index.js'\n\nconst addFieldToProjection = ({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n}: {\n adapter: MongooseAdapter\n databaseSchemaPath: string\n field: FieldAffectingData\n projection: Record<string, true>\n withinLocalizedField: boolean\n}) => {\n const { config } = adapter.payload\n\n if (withinLocalizedField && config.localization) {\n for (const locale of config.localization.localeCodes) {\n const localeDatabaseSchemaPath = databaseSchemaPath.replace('<locale>', locale)\n projection[`${localeDatabaseSchemaPath}${field.name}`] = true\n }\n } else {\n projection[`${databaseSchemaPath}${field.name}`] = true\n }\n}\n\nconst blockTypeField: Field = {\n name: 'blockType',\n type: 'text',\n}\n\nconst traverseFields = ({\n adapter,\n databaseSchemaPath = '',\n fields,\n projection,\n select,\n selectAllOnCurrentLevel = false,\n selectMode,\n withinLocalizedField = false,\n}: {\n adapter: MongooseAdapter\n databaseSchemaPath?: string\n fields: FlattenedField[]\n projection: Record<string, true>\n select: SelectType\n selectAllOnCurrentLevel?: boolean\n selectMode: SelectMode\n withinLocalizedField?: boolean\n}) => {\n for (const field of fields) {\n if (fieldAffectsData(field)) {\n if (selectMode === 'include') {\n if (select[field.name] === true || selectAllOnCurrentLevel) {\n addFieldToProjection({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n })\n continue\n }\n\n if (!select[field.name]) {\n continue\n }\n }\n\n if (selectMode === 'exclude') {\n if (typeof select[field.name] === 'undefined') {\n addFieldToProjection({\n adapter,\n databaseSchemaPath,\n field,\n projection,\n withinLocalizedField,\n })\n continue\n }\n\n if (select[field.name] === false) {\n continue\n }\n }\n }\n\n let fieldDatabaseSchemaPath = databaseSchemaPath\n let fieldWithinLocalizedField = withinLocalizedField\n\n if (fieldAffectsData(field)) {\n fieldDatabaseSchemaPath = `${databaseSchemaPath}${field.name}.`\n\n if (field.localized) {\n fieldDatabaseSchemaPath = `${fieldDatabaseSchemaPath}<locale>.`\n fieldWithinLocalizedField = true\n }\n }\n\n switch (field.type) {\n case 'array':\n case 'group':\n case 'tab': {\n const fieldSelect = select[field.name] as SelectType\n\n if (field.type === 'array' && selectMode === 'include') {\n fieldSelect['id'] = true\n }\n\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: field.flattenedFields,\n projection,\n select: fieldSelect,\n selectMode,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n\n break\n }\n\n case 'blocks': {\n const blocksSelect = select[field.name] as SelectType\n\n for (const block of field.blocks) {\n if (\n (selectMode === 'include' && blocksSelect[block.slug] === true) ||\n (selectMode === 'exclude' && typeof blocksSelect[block.slug] === 'undefined')\n ) {\n addFieldToProjection({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n field: blockTypeField,\n projection,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: block.flattenedFields,\n projection,\n select: {},\n selectAllOnCurrentLevel: true,\n selectMode: 'include',\n withinLocalizedField: fieldWithinLocalizedField,\n })\n continue\n }\n\n let blockSelectMode = selectMode\n\n if (selectMode === 'exclude' && blocksSelect[block.slug] === false) {\n blockSelectMode = 'include'\n }\n\n if (typeof blocksSelect[block.slug] !== 'object') {\n blocksSelect[block.slug] = {}\n }\n\n if (blockSelectMode === 'include') {\n blocksSelect[block.slug]['id'] = true\n addFieldToProjection({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n field: blockTypeField,\n projection,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n }\n\n traverseFields({\n adapter,\n databaseSchemaPath: fieldDatabaseSchemaPath,\n fields: block.flattenedFields,\n projection,\n select: blocksSelect[block.slug] as SelectType,\n selectMode: blockSelectMode,\n withinLocalizedField: fieldWithinLocalizedField,\n })\n }\n\n break\n }\n\n default:\n break\n }\n }\n}\n\nexport const buildProjectionFromSelect = ({\n adapter,\n fields,\n select,\n}: {\n adapter: MongooseAdapter\n fields: FlattenedField[]\n select?: SelectType\n}): Record<string, true> | undefined => {\n if (!select) {\n return\n }\n\n const projection: Record<string, true> = {\n _id: true,\n }\n\n traverseFields({\n adapter,\n fields,\n projection,\n // Clone to safely mutate it later\n select: deepCopyObjectSimple(select),\n selectMode: getSelectMode(select),\n })\n\n return projection\n}\n"],"names":["deepCopyObjectSimple","fieldAffectsData","getSelectMode","addFieldToProjection","adapter","databaseSchemaPath","field","projection","withinLocalizedField","config","payload","localization","locale","localeCodes","localeDatabaseSchemaPath","replace","name","blockTypeField","type","traverseFields","fields","select","selectAllOnCurrentLevel","selectMode","fieldDatabaseSchemaPath","fieldWithinLocalizedField","localized","fieldSelect","flattenedFields","blocksSelect","block","blocks","slug","blockSelectMode","buildProjectionFromSelect","_id"],"mappings":"AAEA,SAASA,oBAAoB,EAAEC,gBAAgB,EAAEC,aAAa,QAAQ,iBAAgB;AAItF,MAAMC,uBAAuB,CAAC,EAC5BC,OAAO,EACPC,kBAAkB,EAClBC,KAAK,EACLC,UAAU,EACVC,oBAAoB,EAOrB;IACC,MAAM,EAAEC,MAAM,EAAE,GAAGL,QAAQM,OAAO;IAElC,IAAIF,wBAAwBC,OAAOE,YAAY,EAAE;QAC/C,KAAK,MAAMC,UAAUH,OAAOE,YAAY,CAACE,WAAW,CAAE;YACpD,MAAMC,2BAA2BT,mBAAmBU,OAAO,CAAC,YAAYH;YACxEL,UAAU,CAAC,GAAGO,2BAA2BR,MAAMU,IAAI,EAAE,CAAC,GAAG;QAC3D;IACF,OAAO;QACLT,UAAU,CAAC,GAAGF,qBAAqBC,MAAMU,IAAI,EAAE,CAAC,GAAG;IACrD;AACF;AAEA,MAAMC,iBAAwB;IAC5BD,MAAM;IACNE,MAAM;AACR;AAEA,MAAMC,iBAAiB,CAAC,EACtBf,OAAO,EACPC,qBAAqB,EAAE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AC,EACxC9B,OAAO,EACPgB,MAAM,EACNC,MAAM,EAKP;IACC,IAAI,CAACA,QAAQ;QACX;IACF;IAEA,MAAMd,aAAmC;QACvC4B,KAAK;IACP;IAEAhB,eAAe;QACbf;QACAgB;QACAb;QACA,kCAAkC;QAClCc,QAAQrB,qBAAqBqB;QAC7BE,YAAYrB,cAAcmB;IAC5B;IAEA,OAAOd;AACT,EAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ClientSession, CollationOptions, Collection } from 'mongodb';
|
|
2
|
+
import type { PipelineStage } from 'mongoose';
|
|
3
|
+
import type { PaginatedDocs } from 'payload';
|
|
4
|
+
import type { MongooseAdapter } from '../index.js';
|
|
5
|
+
export declare const findMany: ({ adapter, collation, collection, joinAgreggation, limit, page, pagination, projection, query, session, skip, sort, useEstimatedCount, }: {
|
|
6
|
+
adapter: MongooseAdapter;
|
|
7
|
+
collation?: CollationOptions;
|
|
8
|
+
collection: Collection;
|
|
9
|
+
joinAgreggation?: PipelineStage[];
|
|
10
|
+
limit?: number;
|
|
11
|
+
page?: number;
|
|
12
|
+
pagination?: boolean;
|
|
13
|
+
projection?: Record<string, unknown>;
|
|
14
|
+
query?: Record<string, unknown>;
|
|
15
|
+
session?: ClientSession;
|
|
16
|
+
skip?: number;
|
|
17
|
+
sort?: Record<string, -1 | 1>;
|
|
18
|
+
useEstimatedCount?: boolean;
|
|
19
|
+
}) => Promise<PaginatedDocs>;
|
|
20
|
+
//# sourceMappingURL=findMany.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findMany.d.ts","sourceRoot":"","sources":["../../src/utilities/findMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAY,MAAM,SAAS,CAAA;AACpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,eAAO,MAAM,QAAQ,6IAclB;IACD,OAAO,EAAE,eAAe,CAAA;IACxB,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,eAAe,CAAC,EAAE,aAAa,EAAE,CAAA;IACjC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B,KAAG,OAAO,CAAC,aAAa,CA6FxB,CAAA"}
|