@payloadcms/db-mongodb 3.9.0 → 3.11.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 +5 -3
- 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.d.ts.map +1 -1
- package/dist/create.js +5 -3
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +5 -3
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +5 -3
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +5 -3
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +3 -4
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +11 -11
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +6 -7
- package/dist/deleteVersions.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +8 -6
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +4 -4
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +6 -5
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +8 -5
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +5 -4
- package/dist/findVersions.js.map +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/predefinedMigrations/migrateRelationshipsV2_V3.js +2 -2
- 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/buildSearchParams.d.ts.map +1 -1
- package/dist/queries/buildSearchParams.js +1 -0
- package/dist/queries/buildSearchParams.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 +17 -6
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +5 -3
- package/dist/queryDrafts.js.map +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +4 -4
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +4 -4
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +4 -4
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +4 -4
- 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.map +1 -1
- package/dist/utilities/buildJoinAggregation.js +6 -2
- package/dist/utilities/buildJoinAggregation.js.map +1 -1
- 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/package.json +4 -4
- package/dist/withSession.d.ts +0 -11
- package/dist/withSession.d.ts.map +0 -1
- package/dist/withSession.js.map +0 -1
package/dist/count.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAQpC,eAAO,MAAM,KAAK,EAAE,KA6CnB,CAAA"}
|
package/dist/count.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { flattenWhereToOperators } from 'payload';
|
|
2
|
-
import {
|
|
3
|
-
export const count = async function count({ collection, locale, req
|
|
2
|
+
import { getSession } from './utilities/getSession.js';
|
|
3
|
+
export const count = async function count({ collection, locale, req, where }) {
|
|
4
4
|
const Model = this.collections[collection];
|
|
5
|
-
const options =
|
|
5
|
+
const options = {
|
|
6
|
+
session: await getSession(this, req)
|
|
7
|
+
};
|
|
6
8
|
let hasNearConstraint = false;
|
|
7
9
|
if (where) {
|
|
8
10
|
const constraints = flattenWhereToOperators(where);
|
package/dist/count.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/count.ts"],"sourcesContent":["import type { CountOptions } from 'mongodb'\nimport type { Count
|
|
1
|
+
{"version":3,"sources":["../src/count.ts"],"sourcesContent":["import type { CountOptions } from 'mongodb'\nimport type { Count } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\n\nexport const count: Count = async function count(\n this: MongooseAdapter,\n { collection, locale, req, where },\n) {\n const Model = this.collections[collection]\n const options: CountOptions = {\n session: await getSession(this, req),\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 const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n\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 options.hint = {\n _id: 1,\n }\n }\n\n let result: number\n if (useEstimatedCount) {\n result = await Model.estimatedDocumentCount({ session: options.session })\n } else {\n result = await Model.countDocuments(query, options)\n }\n\n return {\n totalDocs: result,\n }\n}\n"],"names":["flattenWhereToOperators","getSession","count","collection","locale","req","where","Model","collections","options","session","hasNearConstraint","constraints","some","prop","Object","keys","key","query","buildQuery","payload","useEstimatedCount","length","disableIndexHints","hint","_id","result","estimatedDocumentCount","countDocuments","totalDocs"],"mappings":"AAGA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,QAAe,eAAeA,MAEzC,EAAEC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAElC,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACL,WAAW;IAC1C,MAAMM,UAAwB;QAC5BC,SAAS,MAAMT,WAAW,IAAI,EAAEI;IAClC;IAEA,IAAIM,oBAAoB;IAExB,IAAIL,OAAO;QACT,MAAMM,cAAcZ,wBAAwBM;QAC5CK,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,MAAMC,QAAQ,MAAMX,MAAMY,UAAU,CAAC;QACnCf;QACAgB,SAAS,IAAI,CAACA,OAAO;QACrBd;IACF;IAEA,4HAA4H;IAC5H,MAAMe,oBAAoBV,qBAAqB,CAACO,SAASH,OAAOC,IAAI,CAACE,OAAOI,MAAM,KAAK;IAEvF,IAAI,CAACD,qBAAqBN,OAAOC,IAAI,CAACE,OAAOI,MAAM,KAAK,KAAK,IAAI,CAACC,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5Bd,QAAQe,IAAI,GAAG;YACbC,KAAK;QACP;IACF;IAEA,IAAIC;IACJ,IAAIL,mBAAmB;QACrBK,SAAS,MAAMnB,MAAMoB,sBAAsB,CAAC;YAAEjB,SAASD,QAAQC,OAAO;QAAC;IACzE,OAAO;QACLgB,SAAS,MAAMnB,MAAMqB,cAAc,CAACV,OAAOT;IAC7C;IAEA,OAAO;QACLoB,WAAWH;IACb;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countGlobalVersions.d.ts","sourceRoot":"","sources":["../src/countGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"countGlobalVersions.d.ts","sourceRoot":"","sources":["../src/countGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAQlD,eAAO,MAAM,mBAAmB,EAAE,mBA6CjC,CAAA"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { flattenWhereToOperators } from 'payload';
|
|
2
|
-
import {
|
|
3
|
-
export const countGlobalVersions = async function countGlobalVersions({ global, locale, req
|
|
2
|
+
import { getSession } from './utilities/getSession.js';
|
|
3
|
+
export const countGlobalVersions = async function countGlobalVersions({ global, locale, req, where }) {
|
|
4
4
|
const Model = this.versions[global];
|
|
5
|
-
const options =
|
|
5
|
+
const options = {
|
|
6
|
+
session: await getSession(this, req)
|
|
7
|
+
};
|
|
6
8
|
let hasNearConstraint = false;
|
|
7
9
|
if (where) {
|
|
8
10
|
const constraints = flattenWhereToOperators(where);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/countGlobalVersions.ts"],"sourcesContent":["import type { CountOptions } from 'mongodb'\nimport type { CountGlobalVersions
|
|
1
|
+
{"version":3,"sources":["../src/countGlobalVersions.ts"],"sourcesContent":["import type { CountOptions } from 'mongodb'\nimport type { CountGlobalVersions } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\n\nexport const countGlobalVersions: CountGlobalVersions = async function countGlobalVersions(\n this: MongooseAdapter,\n { global, locale, req, where },\n) {\n const Model = this.versions[global]\n const options: CountOptions = {\n session: await getSession(this, req),\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 const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n\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 options.hint = {\n _id: 1,\n }\n }\n\n let result: number\n if (useEstimatedCount) {\n result = await Model.estimatedDocumentCount({ session: options.session })\n } else {\n result = await Model.countDocuments(query, options)\n }\n\n return {\n totalDocs: result,\n }\n}\n"],"names":["flattenWhereToOperators","getSession","countGlobalVersions","global","locale","req","where","Model","versions","options","session","hasNearConstraint","constraints","some","prop","Object","keys","key","query","buildQuery","payload","useEstimatedCount","length","disableIndexHints","hint","_id","result","estimatedDocumentCount","countDocuments","totalDocs"],"mappings":"AAGA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,sBAA2C,eAAeA,oBAErE,EAAEC,MAAM,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE9B,MAAMC,QAAQ,IAAI,CAACC,QAAQ,CAACL,OAAO;IACnC,MAAMM,UAAwB;QAC5BC,SAAS,MAAMT,WAAW,IAAI,EAAEI;IAClC;IAEA,IAAIM,oBAAoB;IAExB,IAAIL,OAAO;QACT,MAAMM,cAAcZ,wBAAwBM;QAC5CK,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,MAAMC,QAAQ,MAAMX,MAAMY,UAAU,CAAC;QACnCf;QACAgB,SAAS,IAAI,CAACA,OAAO;QACrBd;IACF;IAEA,4HAA4H;IAC5H,MAAMe,oBAAoBV,qBAAqB,CAACO,SAASH,OAAOC,IAAI,CAACE,OAAOI,MAAM,KAAK;IAEvF,IAAI,CAACD,qBAAqBN,OAAOC,IAAI,CAACE,OAAOI,MAAM,KAAK,KAAK,IAAI,CAACC,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5Bd,QAAQe,IAAI,GAAG;YACbC,KAAK;QACP;IACF;IAEA,IAAIC;IACJ,IAAIL,mBAAmB;QACrBK,SAAS,MAAMnB,MAAMoB,sBAAsB,CAAC;YAAEjB,SAASD,QAAQC,OAAO;QAAC;IACzE,OAAO;QACLgB,SAAS,MAAMnB,MAAMqB,cAAc,CAACV,OAAOT;IAC7C;IAEA,OAAO;QACLoB,WAAWH;IACb;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../src/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"countVersions.d.ts","sourceRoot":"","sources":["../src/countVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAQ5C,eAAO,MAAM,aAAa,EAAE,aA6C3B,CAAA"}
|
package/dist/countVersions.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { flattenWhereToOperators } from 'payload';
|
|
2
|
-
import {
|
|
3
|
-
export const countVersions = async function countVersions({ collection, locale, req
|
|
2
|
+
import { getSession } from './utilities/getSession.js';
|
|
3
|
+
export const countVersions = async function countVersions({ collection, locale, req, where }) {
|
|
4
4
|
const Model = this.versions[collection];
|
|
5
|
-
const options =
|
|
5
|
+
const options = {
|
|
6
|
+
session: await getSession(this, req)
|
|
7
|
+
};
|
|
6
8
|
let hasNearConstraint = false;
|
|
7
9
|
if (where) {
|
|
8
10
|
const constraints = flattenWhereToOperators(where);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/countVersions.ts"],"sourcesContent":["import type { CountOptions } from 'mongodb'\nimport type { CountVersions
|
|
1
|
+
{"version":3,"sources":["../src/countVersions.ts"],"sourcesContent":["import type { CountOptions } from 'mongodb'\nimport type { CountVersions } from 'payload'\n\nimport { flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\n\nexport const countVersions: CountVersions = async function countVersions(\n this: MongooseAdapter,\n { collection, locale, req, where },\n) {\n const Model = this.versions[collection]\n const options: CountOptions = {\n session: await getSession(this, req),\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 const query = await Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n\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 options.hint = {\n _id: 1,\n }\n }\n\n let result: number\n if (useEstimatedCount) {\n result = await Model.estimatedDocumentCount({ session: options.session })\n } else {\n result = await Model.countDocuments(query, options)\n }\n\n return {\n totalDocs: result,\n }\n}\n"],"names":["flattenWhereToOperators","getSession","countVersions","collection","locale","req","where","Model","versions","options","session","hasNearConstraint","constraints","some","prop","Object","keys","key","query","buildQuery","payload","useEstimatedCount","length","disableIndexHints","hint","_id","result","estimatedDocumentCount","countDocuments","totalDocs"],"mappings":"AAGA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAElC,MAAMC,QAAQ,IAAI,CAACC,QAAQ,CAACL,WAAW;IACvC,MAAMM,UAAwB;QAC5BC,SAAS,MAAMT,WAAW,IAAI,EAAEI;IAClC;IAEA,IAAIM,oBAAoB;IAExB,IAAIL,OAAO;QACT,MAAMM,cAAcZ,wBAAwBM;QAC5CK,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,MAAMC,QAAQ,MAAMX,MAAMY,UAAU,CAAC;QACnCf;QACAgB,SAAS,IAAI,CAACA,OAAO;QACrBd;IACF;IAEA,4HAA4H;IAC5H,MAAMe,oBAAoBV,qBAAqB,CAACO,SAASH,OAAOC,IAAI,CAACE,OAAOI,MAAM,KAAK;IAEvF,IAAI,CAACD,qBAAqBN,OAAOC,IAAI,CAACE,OAAOI,MAAM,KAAK,KAAK,IAAI,CAACC,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5Bd,QAAQe,IAAI,GAAG;YACbC,KAAK;QACP;IACF;IAEA,IAAIC;IACJ,IAAIL,mBAAmB;QACrBK,SAAS,MAAMnB,MAAMoB,sBAAsB,CAAC;YAAEjB,SAASD,QAAQC,OAAO;QAAC;IACzE,OAAO;QACLgB,SAAS,MAAMnB,MAAMqB,cAAc,CAACV,OAAOT;IAC7C;IAEA,OAAO;QACLoB,WAAWH;IACb;AACF,EAAC"}
|
package/dist/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAY,MAAM,SAAS,CAAA;AAQ/C,eAAO,MAAM,MAAM,EAAE,MAsCpB,CAAA"}
|
package/dist/create.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { getSession } from './utilities/getSession.js';
|
|
1
2
|
import { handleError } from './utilities/handleError.js';
|
|
2
3
|
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
|
3
|
-
|
|
4
|
-
export const create = async function create({ collection, data, req = {} }) {
|
|
4
|
+
export const create = async function create({ collection, data, req }) {
|
|
5
5
|
const Model = this.collections[collection];
|
|
6
|
-
const options =
|
|
6
|
+
const options = {
|
|
7
|
+
session: await getSession(this, req)
|
|
8
|
+
};
|
|
7
9
|
let doc;
|
|
8
10
|
const sanitizedData = sanitizeRelationshipIDs({
|
|
9
11
|
config: this.payload.config,
|
package/dist/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create, Document
|
|
1
|
+
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { CreateOptions } from 'mongoose'\nimport type { Create, Document } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const create: Create = async function create(\n this: MongooseAdapter,\n { collection, data, req },\n) {\n const Model = this.collections[collection]\n const options: CreateOptions = {\n session: await getSession(this, req),\n }\n\n let doc\n\n const sanitizedData = sanitizeRelationshipIDs({\n config: this.payload.config,\n data,\n fields: this.payload.collections[collection].config.fields,\n })\n\n if (this.payload.collections[collection].customIDType) {\n sanitizedData._id = sanitizedData.id\n }\n\n try {\n ;[doc] = await Model.create([sanitizedData], options)\n } catch (error) {\n handleError({ collection, error, req })\n }\n\n // doc.toJSON does not do stuff like converting ObjectIds to string, or date strings to date objects. That's why we use JSON.parse/stringify here\n const result: Document = JSON.parse(JSON.stringify(doc))\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n\n return result\n}\n"],"names":["getSession","handleError","sanitizeRelationshipIDs","create","collection","data","req","Model","collections","options","session","doc","sanitizedData","config","payload","fields","customIDType","_id","id","error","result","JSON","parse","stringify","verificationToken","_verificationToken"],"mappings":"AAKA,SAASA,UAAU,QAAQ,4BAA2B;AACtD,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,UAAU,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzB,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACJ,WAAW;IAC1C,MAAMK,UAAyB;QAC7BC,SAAS,MAAMV,WAAW,IAAI,EAAEM;IAClC;IAEA,IAAIK;IAEJ,MAAMC,gBAAgBV,wBAAwB;QAC5CW,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BR;QACAU,QAAQ,IAAI,CAACD,OAAO,CAACN,WAAW,CAACJ,WAAW,CAACS,MAAM,CAACE,MAAM;IAC5D;IAEA,IAAI,IAAI,CAACD,OAAO,CAACN,WAAW,CAACJ,WAAW,CAACY,YAAY,EAAE;QACrDJ,cAAcK,GAAG,GAAGL,cAAcM,EAAE;IACtC;IAEA,IAAI;;QACD,CAACP,IAAI,GAAG,MAAMJ,MAAMJ,MAAM,CAAC;YAACS;SAAc,EAAEH;IAC/C,EAAE,OAAOU,OAAO;QACdlB,YAAY;YAAEG;YAAYe;YAAOb;QAAI;IACvC;IAEA,iJAAiJ;IACjJ,MAAMc,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACZ;IACnD,MAAMa,oBAAoBb,IAAIc,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOF,EAAE,GAAGE,OAAOH,GAAG;IACtB,IAAIO,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IAEA,OAAOJ;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAQ3C,eAAO,MAAM,YAAY,EAAE,YA4B1B,CAAA"}
|
package/dist/createGlobal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { getSession } from './utilities/getSession.js';
|
|
1
2
|
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
2
3
|
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
|
3
|
-
|
|
4
|
-
export const createGlobal = async function createGlobal({ slug, data, req = {} }) {
|
|
4
|
+
export const createGlobal = async function createGlobal({ slug, data, req }) {
|
|
5
5
|
const Model = this.globals;
|
|
6
6
|
const global = sanitizeRelationshipIDs({
|
|
7
7
|
config: this.payload.config,
|
|
@@ -11,7 +11,9 @@ export const createGlobal = async function createGlobal({ slug, data, req = {} }
|
|
|
11
11
|
},
|
|
12
12
|
fields: this.payload.config.globals.find((globalConfig)=>globalConfig.slug === slug).fields
|
|
13
13
|
});
|
|
14
|
-
const options =
|
|
14
|
+
const options = {
|
|
15
|
+
session: await getSession(this, req)
|
|
16
|
+
};
|
|
15
17
|
let [result] = await Model.create([
|
|
16
18
|
global
|
|
17
19
|
], options);
|
package/dist/createGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobal
|
|
1
|
+
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateOptions } from 'mongoose'\nimport type { CreateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const createGlobal: CreateGlobal = async function createGlobal(\n this: MongooseAdapter,\n { slug, data, req },\n) {\n const Model = this.globals\n\n const global = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: {\n globalType: slug,\n ...data,\n },\n fields: this.payload.config.globals.find((globalConfig) => globalConfig.slug === slug).fields,\n })\n\n const options: CreateOptions = {\n session: await getSession(this, req),\n }\n\n let [result] = (await Model.create([global], options)) as any\n\n result = JSON.parse(JSON.stringify(result))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["getSession","sanitizeInternalFields","sanitizeRelationshipIDs","createGlobal","slug","data","req","Model","globals","global","config","payload","globalType","fields","find","globalConfig","options","session","result","create","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAC9E,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEnB,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAE1B,MAAMC,SAASP,wBAAwB;QACrCQ,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BL,MAAM;YACJO,YAAYR;YACZ,GAAGC,IAAI;QACT;QACAQ,QAAQ,IAAI,CAACF,OAAO,CAACD,MAAM,CAACF,OAAO,CAACM,IAAI,CAAC,CAACC,eAAiBA,aAAaX,IAAI,KAAKA,MAAMS,MAAM;IAC/F;IAEA,MAAMG,UAAyB;QAC7BC,SAAS,MAAMjB,WAAW,IAAI,EAAEM;IAClC;IAEA,IAAI,CAACY,OAAO,GAAI,MAAMX,MAAMY,MAAM,CAAC;QAACV;KAAO,EAAEO;IAE7CE,SAASE,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACJ;IAEnC,uBAAuB;IACvBA,OAAOK,EAAE,GAAGL,OAAOM,GAAG;IACtBN,SAASjB,uBAAuBiB;IAEhC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4B,KAAK,mBAAmB,EAAiB,MAAM,SAAS,CAAA;AAO3F,eAAO,MAAM,mBAAmB,EAAE,mBAwEjC,CAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { buildVersionGlobalFields } from 'payload';
|
|
2
|
+
import { getSession } from './utilities/getSession.js';
|
|
2
3
|
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
|
3
|
-
|
|
4
|
-
export const createGlobalVersion = async function createGlobalVersion({ autosave, createdAt, globalSlug, parent, publishedLocale, req = {}, snapshot, updatedAt, versionData }) {
|
|
4
|
+
export const createGlobalVersion = async function createGlobalVersion({ autosave, createdAt, globalSlug, parent, publishedLocale, req, snapshot, updatedAt, versionData }) {
|
|
5
5
|
const VersionModel = this.versions[globalSlug];
|
|
6
|
-
const options =
|
|
6
|
+
const options = {
|
|
7
|
+
session: await getSession(this, req)
|
|
8
|
+
};
|
|
7
9
|
const data = sanitizeRelationshipIDs({
|
|
8
10
|
config: this.payload.config,
|
|
9
11
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import {\n
|
|
1
|
+
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { CreateOptions } from 'mongoose'\n\nimport { buildVersionGlobalFields, type CreateGlobalVersion, type Document } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const createGlobalVersion: CreateGlobalVersion = async function createGlobalVersion(\n this: MongooseAdapter,\n {\n autosave,\n createdAt,\n globalSlug,\n parent,\n publishedLocale,\n req,\n snapshot,\n updatedAt,\n versionData,\n },\n) {\n const VersionModel = this.versions[globalSlug]\n const options: CreateOptions = {\n session: await getSession(this, req),\n }\n\n const data = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: {\n autosave,\n createdAt,\n latest: true,\n parent,\n publishedLocale,\n snapshot,\n updatedAt,\n version: versionData,\n },\n fields: buildVersionGlobalFields(\n this.payload.config,\n this.payload.config.globals.find((global) => global.slug === globalSlug),\n ),\n })\n\n const [doc] = await VersionModel.create([data], options, req)\n\n await VersionModel.updateMany(\n {\n $and: [\n {\n _id: {\n $ne: doc._id,\n },\n },\n {\n parent: {\n $eq: parent,\n },\n },\n {\n latest: {\n $eq: true,\n },\n },\n ],\n },\n { $unset: { latest: 1 } },\n options,\n )\n\n const result: Document = JSON.parse(JSON.stringify(doc))\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["buildVersionGlobalFields","getSession","sanitizeRelationshipIDs","createGlobalVersion","autosave","createdAt","globalSlug","parent","publishedLocale","req","snapshot","updatedAt","versionData","VersionModel","versions","options","session","data","config","payload","latest","version","fields","globals","find","global","slug","doc","create","updateMany","$and","_id","$ne","$eq","$unset","result","JSON","parse","stringify","verificationToken","_verificationToken","id"],"mappings":"AAEA,SAASA,wBAAwB,QAAiD,UAAS;AAI3F,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,sBAA2C,eAAeA,oBAErE,EACEC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,MAAM,EACNC,eAAe,EACfC,GAAG,EACHC,QAAQ,EACRC,SAAS,EACTC,WAAW,EACZ;IAED,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACR,WAAW;IAC9C,MAAMS,UAAyB;QAC7BC,SAAS,MAAMf,WAAW,IAAI,EAAEQ;IAClC;IAEA,MAAMQ,OAAOf,wBAAwB;QACnCgB,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BD,MAAM;YACJb;YACAC;YACAe,QAAQ;YACRb;YACAC;YACAE;YACAC;YACAU,SAAST;QACX;QACAU,QAAQtB,yBACN,IAAI,CAACmB,OAAO,CAACD,MAAM,EACnB,IAAI,CAACC,OAAO,CAACD,MAAM,CAACK,OAAO,CAACC,IAAI,CAAC,CAACC,SAAWA,OAAOC,IAAI,KAAKpB;IAEjE;IAEA,MAAM,CAACqB,IAAI,GAAG,MAAMd,aAAae,MAAM,CAAC;QAACX;KAAK,EAAEF,SAASN;IAEzD,MAAMI,aAAagB,UAAU,CAC3B;QACEC,MAAM;YACJ;gBACEC,KAAK;oBACHC,KAAKL,IAAII,GAAG;gBACd;YACF;YACA;gBACExB,QAAQ;oBACN0B,KAAK1B;gBACP;YACF;YACA;gBACEa,QAAQ;oBACNa,KAAK;gBACP;YACF;SACD;IACH,GACA;QAAEC,QAAQ;YAAEd,QAAQ;QAAE;IAAE,GACxBL;IAGF,MAAMoB,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACX;IACnD,MAAMY,oBAAoBZ,IAAIa,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOM,EAAE,GAAGN,OAAOJ,GAAG;IACtB,IAAIQ,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgC,KAAK,aAAa,EAAiB,MAAM,SAAS,CAAA;AAOzF,eAAO,MAAM,aAAa,EAAE,aA0F3B,CAAA"}
|
package/dist/createVersion.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Types } from 'mongoose';
|
|
2
2
|
import { buildVersionCollectionFields } from 'payload';
|
|
3
|
+
import { getSession } from './utilities/getSession.js';
|
|
3
4
|
import { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js';
|
|
4
|
-
|
|
5
|
-
export const createVersion = async function createVersion({ autosave, collectionSlug, createdAt, parent, publishedLocale, req = {}, snapshot, updatedAt, versionData }) {
|
|
5
|
+
export const createVersion = async function createVersion({ autosave, collectionSlug, createdAt, parent, publishedLocale, req, snapshot, updatedAt, versionData }) {
|
|
6
6
|
const VersionModel = this.versions[collectionSlug];
|
|
7
|
-
const options =
|
|
7
|
+
const options = {
|
|
8
|
+
session: await getSession(this, req)
|
|
9
|
+
};
|
|
8
10
|
const data = sanitizeRelationshipIDs({
|
|
9
11
|
config: this.payload.config,
|
|
10
12
|
data: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import { Types } from 'mongoose'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateOptions } from 'mongoose'\n\nimport { Types } from 'mongoose'\nimport { buildVersionCollectionFields, type CreateVersion, type Document } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeRelationshipIDs } from './utilities/sanitizeRelationshipIDs.js'\n\nexport const createVersion: CreateVersion = async function createVersion(\n this: MongooseAdapter,\n {\n autosave,\n collectionSlug,\n createdAt,\n parent,\n publishedLocale,\n req,\n snapshot,\n updatedAt,\n versionData,\n },\n) {\n const VersionModel = this.versions[collectionSlug]\n const options: CreateOptions = {\n session: await getSession(this, req),\n }\n\n const data = sanitizeRelationshipIDs({\n config: this.payload.config,\n data: {\n autosave,\n createdAt,\n latest: true,\n parent,\n publishedLocale,\n snapshot,\n updatedAt,\n version: versionData,\n },\n fields: buildVersionCollectionFields(\n this.payload.config,\n this.payload.collections[collectionSlug].config,\n ),\n })\n\n const [doc] = await VersionModel.create([data], options, req)\n\n const parentQuery = {\n $or: [\n {\n parent: {\n $eq: data.parent,\n },\n },\n ],\n }\n if (data.parent instanceof Types.ObjectId) {\n parentQuery.$or.push({\n parent: {\n $eq: data.parent.toString(),\n },\n })\n }\n\n await VersionModel.updateMany(\n {\n $and: [\n {\n _id: {\n $ne: doc._id,\n },\n },\n parentQuery,\n {\n latest: {\n $eq: true,\n },\n },\n {\n updatedAt: {\n $lt: new Date(doc.updatedAt),\n },\n },\n ],\n },\n { $unset: { latest: 1 } },\n options,\n )\n\n const result: Document = JSON.parse(JSON.stringify(doc))\n const verificationToken = doc._verificationToken\n\n // custom id type reset\n result.id = result._id\n if (verificationToken) {\n result._verificationToken = verificationToken\n }\n return result\n}\n"],"names":["Types","buildVersionCollectionFields","getSession","sanitizeRelationshipIDs","createVersion","autosave","collectionSlug","createdAt","parent","publishedLocale","req","snapshot","updatedAt","versionData","VersionModel","versions","options","session","data","config","payload","latest","version","fields","collections","doc","create","parentQuery","$or","$eq","ObjectId","push","toString","updateMany","$and","_id","$ne","$lt","Date","$unset","result","JSON","parse","stringify","verificationToken","_verificationToken","id"],"mappings":"AAEA,SAASA,KAAK,QAAQ,WAAU;AAChC,SAASC,4BAA4B,QAA2C,UAAS;AAIzF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,uBAAuB,QAAQ,yCAAwC;AAEhF,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EACEC,QAAQ,EACRC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,eAAe,EACfC,GAAG,EACHC,QAAQ,EACRC,SAAS,EACTC,WAAW,EACZ;IAED,MAAMC,eAAe,IAAI,CAACC,QAAQ,CAACT,eAAe;IAClD,MAAMU,UAAyB;QAC7BC,SAAS,MAAMf,WAAW,IAAI,EAAEQ;IAClC;IAEA,MAAMQ,OAAOf,wBAAwB;QACnCgB,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BD,MAAM;YACJb;YACAE;YACAc,QAAQ;YACRb;YACAC;YACAE;YACAC;YACAU,SAAST;QACX;QACAU,QAAQtB,6BACN,IAAI,CAACmB,OAAO,CAACD,MAAM,EACnB,IAAI,CAACC,OAAO,CAACI,WAAW,CAAClB,eAAe,CAACa,MAAM;IAEnD;IAEA,MAAM,CAACM,IAAI,GAAG,MAAMX,aAAaY,MAAM,CAAC;QAACR;KAAK,EAAEF,SAASN;IAEzD,MAAMiB,cAAc;QAClBC,KAAK;YACH;gBACEpB,QAAQ;oBACNqB,KAAKX,KAAKV,MAAM;gBAClB;YACF;SACD;IACH;IACA,IAAIU,KAAKV,MAAM,YAAYR,MAAM8B,QAAQ,EAAE;QACzCH,YAAYC,GAAG,CAACG,IAAI,CAAC;YACnBvB,QAAQ;gBACNqB,KAAKX,KAAKV,MAAM,CAACwB,QAAQ;YAC3B;QACF;IACF;IAEA,MAAMlB,aAAamB,UAAU,CAC3B;QACEC,MAAM;YACJ;gBACEC,KAAK;oBACHC,KAAKX,IAAIU,GAAG;gBACd;YACF;YACAR;YACA;gBACEN,QAAQ;oBACNQ,KAAK;gBACP;YACF;YACA;gBACEjB,WAAW;oBACTyB,KAAK,IAAIC,KAAKb,IAAIb,SAAS;gBAC7B;YACF;SACD;IACH,GACA;QAAE2B,QAAQ;YAAElB,QAAQ;QAAE;IAAE,GACxBL;IAGF,MAAMwB,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAAClB;IACnD,MAAMmB,oBAAoBnB,IAAIoB,kBAAkB;IAEhD,uBAAuB;IACvBL,OAAOM,EAAE,GAAGN,OAAOL,GAAG;IACtB,IAAIS,mBAAmB;QACrBJ,OAAOK,kBAAkB,GAAGD;IAC9B;IACA,OAAOJ;AACT,EAAC"}
|
package/dist/deleteMany.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteMany.d.ts","sourceRoot":"","sources":["../src/deleteMany.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deleteMany.d.ts","sourceRoot":"","sources":["../src/deleteMany.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,eAAO,MAAM,UAAU,EAAE,UAexB,CAAA"}
|
package/dist/deleteMany.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const deleteMany = async function deleteMany({ collection, req
|
|
1
|
+
import { getSession } from './utilities/getSession.js';
|
|
2
|
+
export const deleteMany = async function deleteMany({ collection, req, where }) {
|
|
3
3
|
const Model = this.collections[collection];
|
|
4
4
|
const options = {
|
|
5
|
-
|
|
6
|
-
lean: true
|
|
5
|
+
session: await getSession(this, req)
|
|
7
6
|
};
|
|
8
7
|
const query = await Model.buildQuery({
|
|
9
8
|
payload: this.payload,
|
package/dist/deleteMany.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteMany
|
|
1
|
+
{"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteOptions } from 'mongodb'\nimport type { DeleteMany } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { getSession } from './utilities/getSession.js'\n\nexport const deleteMany: DeleteMany = async function deleteMany(\n this: MongooseAdapter,\n { collection, req, where },\n) {\n const Model = this.collections[collection]\n const options: DeleteOptions = {\n session: await getSession(this, req),\n }\n\n const query = await Model.buildQuery({\n payload: this.payload,\n where,\n })\n\n await Model.deleteMany(query, options)\n}\n"],"names":["getSession","deleteMany","collection","req","where","Model","collections","options","session","query","buildQuery","payload"],"mappings":"AAKA,SAASA,UAAU,QAAQ,4BAA2B;AAEtD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,UAAU,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE1B,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACJ,WAAW;IAC1C,MAAMK,UAAyB;QAC7BC,SAAS,MAAMR,WAAW,IAAI,EAAEG;IAClC;IAEA,MAAMM,QAAQ,MAAMJ,MAAMK,UAAU,CAAC;QACnCC,SAAS,IAAI,CAACA,OAAO;QACrBP;IACF;IAEA,MAAMC,MAAMJ,UAAU,CAACQ,OAAOF;AAChC,EAAC"}
|
package/dist/deleteOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,SAAS,CAAA;AAQlD,eAAO,MAAM,SAAS,EAAE,SA4BvB,CAAA"}
|
package/dist/deleteOne.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
2
|
+
import { getSession } from './utilities/getSession.js';
|
|
2
3
|
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
3
|
-
|
|
4
|
-
export const deleteOne = async function deleteOne({ collection, req = {}, select, where }) {
|
|
4
|
+
export const deleteOne = async function deleteOne({ collection, req, select, where }) {
|
|
5
5
|
const Model = this.collections[collection];
|
|
6
|
-
const options =
|
|
7
|
-
const query = await Model.buildQuery({
|
|
8
|
-
payload: this.payload,
|
|
9
|
-
where
|
|
10
|
-
});
|
|
11
|
-
const doc = await Model.findOneAndDelete(query, {
|
|
12
|
-
...options,
|
|
6
|
+
const options = {
|
|
13
7
|
projection: buildProjectionFromSelect({
|
|
14
8
|
adapter: this,
|
|
15
9
|
fields: this.payload.collections[collection].config.flattenedFields,
|
|
16
10
|
select
|
|
17
|
-
})
|
|
18
|
-
|
|
11
|
+
}),
|
|
12
|
+
session: await getSession(this, req)
|
|
13
|
+
};
|
|
14
|
+
const query = await Model.buildQuery({
|
|
15
|
+
payload: this.payload,
|
|
16
|
+
where
|
|
17
|
+
});
|
|
18
|
+
const doc = await Model.findOneAndDelete(query, options).lean();
|
|
19
19
|
let result = JSON.parse(JSON.stringify(doc));
|
|
20
20
|
// custom id type reset
|
|
21
21
|
result.id = result._id;
|
package/dist/deleteOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne, Document
|
|
1
|
+
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { DeleteOne, Document } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getSession } from './utilities/getSession.js'\nimport { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: MongooseAdapter,\n { collection, req, select, where },\n) {\n const Model = this.collections[collection]\n const options: QueryOptions = {\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.collections[collection].config.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await Model.buildQuery({\n payload: this.payload,\n where,\n })\n\n const doc = await Model.findOneAndDelete(query, options).lean()\n\n let result: Document = JSON.parse(JSON.stringify(doc))\n\n // custom id type reset\n result.id = result._id\n result = sanitizeInternalFields(result)\n\n return result\n}\n"],"names":["buildProjectionFromSelect","getSession","sanitizeInternalFields","deleteOne","collection","req","select","where","Model","collections","options","projection","adapter","fields","payload","config","flattenedFields","session","query","buildQuery","doc","findOneAndDelete","lean","result","JSON","parse","stringify","id","_id"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAE9E,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,UAAU,EAAEC,GAAG,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAElC,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACL,WAAW;IAC1C,MAAMM,UAAwB;QAC5BC,YAAYX,0BAA0B;YACpCY,SAAS,IAAI;YACbC,QAAQ,IAAI,CAACC,OAAO,CAACL,WAAW,CAACL,WAAW,CAACW,MAAM,CAACC,eAAe;YACnEV;QACF;QACAW,SAAS,MAAMhB,WAAW,IAAI,EAAEI;IAClC;IAEA,MAAMa,QAAQ,MAAMV,MAAMW,UAAU,CAAC;QACnCL,SAAS,IAAI,CAACA,OAAO;QACrBP;IACF;IAEA,MAAMa,MAAM,MAAMZ,MAAMa,gBAAgB,CAACH,OAAOR,SAASY,IAAI;IAE7D,IAAIC,SAAmBC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAEjD,uBAAuB;IACvBG,OAAOI,EAAE,GAAGJ,OAAOK,GAAG;IACtBL,SAASrB,uBAAuBqB;IAEhC,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,eAAO,MAAM,cAAc,EAAE,cAe5B,CAAA"}
|
package/dist/deleteVersions.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const deleteVersions = async function deleteVersions({ collection, locale, req
|
|
1
|
+
import { getSession } from './utilities/getSession.js';
|
|
2
|
+
export const deleteVersions = async function deleteVersions({ collection, locale, req, where }) {
|
|
3
3
|
const VersionsModel = this.versions[collection];
|
|
4
|
-
const
|
|
5
|
-
...await withSession(this, req),
|
|
6
|
-
lean: true
|
|
7
|
-
};
|
|
4
|
+
const session = await getSession(this, req);
|
|
8
5
|
const query = await VersionsModel.buildQuery({
|
|
9
6
|
locale,
|
|
10
7
|
payload: this.payload,
|
|
11
8
|
where
|
|
12
9
|
});
|
|
13
|
-
await VersionsModel.deleteMany(query,
|
|
10
|
+
await VersionsModel.deleteMany(query, {
|
|
11
|
+
session
|
|
12
|
+
});
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=deleteVersions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions
|
|
1
|
+
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\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 VersionsModel.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n await VersionsModel.deleteMany(query, { session })\n}\n"],"names":["getSession","deleteVersions","collection","locale","req","where","VersionsModel","versions","session","query","buildQuery","payload","deleteMany"],"mappings":"AAIA,SAASA,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,MAAMH,cAAcI,UAAU,CAAC;QAC3CP;QACAQ,SAAS,IAAI,CAACA,OAAO;QACrBN;IACF;IAEA,MAAMC,cAAcM,UAAU,CAACH,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,
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAYnC,eAAO,MAAM,IAAI,EAAE,IAgIlB,CAAA"}
|
package/dist/find.js
CHANGED
|
@@ -2,12 +2,12 @@ import { flattenWhereToOperators } from 'payload';
|
|
|
2
2
|
import { buildSortParam } from './queries/buildSortParam.js';
|
|
3
3
|
import { buildJoinAggregation } from './utilities/buildJoinAggregation.js';
|
|
4
4
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
5
|
+
import { getSession } from './utilities/getSession.js';
|
|
5
6
|
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
6
|
-
|
|
7
|
-
export const find = async function find({ collection, joins = {}, limit = 0, locale, page, pagination, projection, req = {}, select, sort: sortArg, where }) {
|
|
7
|
+
export const find = async function find({ collection, joins = {}, limit = 0, locale, page, pagination, projection, req, select, sort: sortArg, where }) {
|
|
8
8
|
const Model = this.collections[collection];
|
|
9
9
|
const collectionConfig = this.payload.collections[collection].config;
|
|
10
|
-
const
|
|
10
|
+
const session = await getSession(this, req);
|
|
11
11
|
let hasNearConstraint = false;
|
|
12
12
|
if (where) {
|
|
13
13
|
const constraints = flattenWhereToOperators(where);
|
|
@@ -33,7 +33,9 @@ export const find = async function find({ collection, joins = {}, limit = 0, loc
|
|
|
33
33
|
const paginationOptions = {
|
|
34
34
|
lean: true,
|
|
35
35
|
leanWithId: true,
|
|
36
|
-
options
|
|
36
|
+
options: {
|
|
37
|
+
session
|
|
38
|
+
},
|
|
37
39
|
page,
|
|
38
40
|
pagination,
|
|
39
41
|
projection,
|
|
@@ -61,10 +63,10 @@ export const find = async function find({ collection, joins = {}, limit = 0, loc
|
|
|
61
63
|
// the correct indexed field
|
|
62
64
|
paginationOptions.useCustomCountFn = ()=>{
|
|
63
65
|
return Promise.resolve(Model.countDocuments(query, {
|
|
64
|
-
...options,
|
|
65
66
|
hint: {
|
|
66
67
|
_id: 1
|
|
67
|
-
}
|
|
68
|
+
},
|
|
69
|
+
session
|
|
68
70
|
}));
|
|
69
71
|
};
|
|
70
72
|
}
|
package/dist/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { PaginateOptions } from 'mongoose'\nimport type { Find
|
|
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 { sanitizeInternalFields } from './utilities/sanitizeInternalFields.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 Model.buildQuery({\n locale,\n payload: this.payload,\n where,\n })\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n 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 const docs = JSON.parse(JSON.stringify(result.docs))\n\n return {\n ...result,\n docs: docs.map((doc) => {\n doc.id = doc._id\n return sanitizeInternalFields(doc)\n }),\n }\n}\n"],"names":["flattenWhereToOperators","buildSortParam","buildJoinAggregation","buildProjectionFromSelect","getSession","sanitizeInternalFields","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","buildQuery","useEstimatedCount","length","paginationOptions","lean","leanWithId","options","adapter","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","aggregate","aggregatePaginate","paginate","docs","JSON","parse","stringify","map","doc","id"],"mappings":"AAGA,SAASA,uBAAuB,QAAQ,UAAS;AAIjD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAE9E,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,QAAQ,CAAC,CAAC,EACVC,QAAQ,CAAC,EACTC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,QAAQ,IAAI,CAACC,WAAW,CAACb,WAAW;IAC1C,MAAMc,mBAAmB,IAAI,CAACC,OAAO,CAACF,WAAW,CAACb,WAAW,CAACgB,MAAM;IAEpE,MAAMC,UAAU,MAAMpB,WAAW,IAAI,EAAEU;IAEvC,IAAIW,oBAAoB;IAExB,IAAIP,OAAO;QACT,MAAMQ,cAAc1B,wBAAwBkB;QAC5CO,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIf;IACJ,IAAI,CAACS,mBAAmB;QACtBT,OAAOf,eAAe;YACpBsB,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;YAC3BS,QAAQX,iBAAiBY,eAAe;YACxCvB;YACAM,MAAMC,WAAWI,iBAAiBa,WAAW;YAC7CC,YAAY;QACd;IACF;IAEA,MAAMC,QAAQ,MAAMjB,MAAMkB,UAAU,CAAC;QACnC3B;QACAY,SAAS,IAAI,CAACA,OAAO;QACrBJ;IACF;IAEA,4HAA4H;IAC5H,MAAMoB,oBAAoBb,qBAAqB,CAACW,SAASP,OAAOC,IAAI,CAACM,OAAOG,MAAM,KAAK;IACvF,MAAMC,oBAAqC;QACzCC,MAAM;QACNC,YAAY;QACZC,SAAS;YACPnB;QACF;QACAb;QACAC;QACAC;QACAG;QACAsB;IACF;IAEA,IAAIvB,QAAQ;QACVyB,kBAAkB3B,UAAU,GAAGV,0BAA0B;YACvDyC,SAAS,IAAI;YACbZ,QAAQX,iBAAiBY,eAAe;YACxClB;QACF;IACF;IAEA,IAAI,IAAI,CAAC8B,SAAS,EAAE;QAClB,MAAMC,gBAAgB;QACtBN,kBAAkBK,SAAS,GAAG;YAC5BnC,QAAQA,UAAUA,WAAW,SAASA,WAAW,MAAMA,SAASoC;YAChE,GAAG,IAAI,CAACD,SAAS;QACnB;IACF;IAEA,IAAI,CAACP,qBAAqBT,OAAOC,IAAI,CAACM,OAAOG,MAAM,KAAK,KAAK,IAAI,CAACQ,iBAAiB,KAAK,MAAM;QAC5F,mHAAmH;QACnH,qHAAqH;QACrH,mHAAmH;QACnH,4BAA4B;QAC5BP,kBAAkBQ,gBAAgB,GAAG;YACnC,OAAOC,QAAQC,OAAO,CACpB/B,MAAMgC,cAAc,CAACf,OAAO;gBAC1BgB,MAAM;oBAAEC,KAAK;gBAAE;gBACf7B;YACF;QAEJ;IACF;IAEA,IAAIf,SAAS,GAAG;QACd+B,kBAAkB/B,KAAK,GAAGA;QAC1B,qEAAqE;QACrE+B,kBAAkBG,OAAO,CAAClC,KAAK,GAAGA;QAElC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACf+B,kBAAkB5B,UAAU,GAAG;QACjC;IACF;IAEA,IAAI0C;IAEJ,MAAMC,YAAY,MAAMrD,qBAAqB;QAC3C0C,SAAS,IAAI;QACbrC;QACAc;QACAb;QACAE;QACA0B;IACF;IACA,yBAAyB;IACzB,IAAImB,WAAW;QACbD,SAAS,MAAMnC,MAAMqC,iBAAiB,CAACrC,MAAMoC,SAAS,CAACA,YAAYf;IACrE,OAAO;QACLc,SAAS,MAAMnC,MAAMsC,QAAQ,CAACrB,OAAOI;IACvC;IAEA,MAAMkB,OAAOC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACP,OAAOI,IAAI;IAElD,OAAO;QACL,GAAGJ,MAAM;QACTI,MAAMA,KAAKI,GAAG,CAAC,CAACC;YACdA,IAAIC,EAAE,GAAGD,IAAIV,GAAG;YAChB,OAAOhD,uBAAuB0D;QAChC;IACF;AACF,EAAC"}
|
package/dist/findGlobal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAUzC,eAAO,MAAM,UAAU,EAAE,UAoCxB,CAAA"}
|
package/dist/findGlobal.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { combineQueries } from 'payload';
|
|
2
2
|
import { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js';
|
|
3
|
+
import { getSession } from './utilities/getSession.js';
|
|
3
4
|
import { sanitizeInternalFields } from './utilities/sanitizeInternalFields.js';
|
|
4
|
-
|
|
5
|
-
export const findGlobal = async function findGlobal({ slug, locale, req = {}, select, where }) {
|
|
5
|
+
export const findGlobal = async function findGlobal({ slug, locale, req, select, where }) {
|
|
6
6
|
const Model = this.globals;
|
|
7
7
|
const options = {
|
|
8
|
-
...await withSession(this, req),
|
|
9
8
|
lean: true,
|
|
10
9
|
select: buildProjectionFromSelect({
|
|
11
10
|
adapter: this,
|
|
12
11
|
fields: this.payload.globals.config.find((each)=>each.slug === slug).flattenedFields,
|
|
13
12
|
select
|
|
14
|
-
})
|
|
13
|
+
}),
|
|
14
|
+
session: await getSession(this, req)
|
|
15
15
|
};
|
|
16
16
|
const query = await Model.buildQuery({
|
|
17
17
|
globalSlug: slug,
|
package/dist/findGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal
|
|
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 { sanitizeInternalFields } from './utilities/sanitizeInternalFields.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 options: QueryOptions = {\n lean: true,\n select: buildProjectionFromSelect({\n adapter: this,\n fields: this.payload.globals.config.find((each) => each.slug === slug).flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const query = await Model.buildQuery({\n globalSlug: slug,\n locale,\n payload: this.payload,\n where: combineQueries({ globalType: { equals: slug } }, where),\n })\n\n let doc = (await Model.findOne(query, {}, options)) as any\n\n if (!doc) {\n return null\n }\n if (doc._id) {\n doc.id = doc._id\n delete doc._id\n }\n\n doc = JSON.parse(JSON.stringify(doc))\n doc = sanitizeInternalFields(doc)\n\n return doc\n}\n"],"names":["combineQueries","buildProjectionFromSelect","getSession","sanitizeInternalFields","findGlobal","slug","locale","req","select","where","Model","globals","options","lean","adapter","fields","payload","config","find","each","flattenedFields","session","query","buildQuery","globalSlug","globalType","equals","doc","findOne","_id","id","JSON","parse","stringify"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,sBAAsB,QAAQ,wCAAuC;AAE9E,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,KAAK,EAAE;IAEpC,MAAMC,QAAQ,IAAI,CAACC,OAAO;IAC1B,MAAMC,UAAwB;QAC5BC,MAAM;QACNL,QAAQP,0BAA0B;YAChCa,SAAS,IAAI;YACbC,QAAQ,IAAI,CAACC,OAAO,CAACL,OAAO,CAACM,MAAM,CAACC,IAAI,CAAC,CAACC,OAASA,KAAKd,IAAI,KAAKA,MAAMe,eAAe;YACtFZ;QACF;QACAa,SAAS,MAAMnB,WAAW,IAAI,EAAEK;IAClC;IAEA,MAAMe,QAAQ,MAAMZ,MAAMa,UAAU,CAAC;QACnCC,YAAYnB;QACZC;QACAU,SAAS,IAAI,CAACA,OAAO;QACrBP,OAAOT,eAAe;YAAEyB,YAAY;gBAAEC,QAAQrB;YAAK;QAAE,GAAGI;IAC1D;IAEA,IAAIkB,MAAO,MAAMjB,MAAMkB,OAAO,CAACN,OAAO,CAAC,GAAGV;IAE1C,IAAI,CAACe,KAAK;QACR,OAAO;IACT;IACA,IAAIA,IAAIE,GAAG,EAAE;QACXF,IAAIG,EAAE,GAAGH,IAAIE,GAAG;QAChB,OAAOF,IAAIE,GAAG;IAChB;IAEAF,MAAMI,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAChCA,MAAMxB,uBAAuBwB;IAE7B,OAAOA;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAWjD,eAAO,MAAM,kBAAkB,EAAE,kBAqGhC,CAAA"}
|