@payloadcms/db-mongodb 3.65.0-internal.ef3958a → 3.65.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.js +3 -3
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.js +3 -3
- package/dist/countGlobalVersions.js.map +1 -1
- package/dist/countVersions.js +3 -3
- package/dist/countVersions.js.map +1 -1
- package/dist/create.js +5 -5
- package/dist/create.js.map +1 -1
- package/dist/createGlobalVersion.js +5 -5
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.js +5 -5
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.js +3 -3
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.js +6 -6
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.js +1 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/exports/internal.d.ts +2 -0
- package/dist/exports/internal.d.ts.map +1 -0
- package/dist/exports/internal.js +3 -0
- package/dist/exports/internal.js.map +1 -0
- package/dist/find.js +1 -1
- package/dist/find.js.map +1 -1
- package/dist/findDistinct.js +1 -1
- package/dist/findDistinct.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +9 -9
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.js +6 -6
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.js +5 -5
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.js +6 -6
- package/dist/findVersions.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +4 -3
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +12 -6
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js +8 -10
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/updateGlobal.js +7 -7
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +12 -12
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateJobs.js +7 -7
- package/dist/updateJobs.js.map +1 -1
- package/dist/updateMany.js +13 -13
- package/dist/updateMany.js.map +1 -1
- package/dist/updateOne.js +13 -13
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.js +12 -12
- package/dist/updateVersion.js.map +1 -1
- package/dist/utilities/getSession.d.ts.map +1 -1
- package/dist/utilities/getSession.js +14 -1
- package/dist/utilities/getSession.js.map +1 -1
- package/dist/utilities/transform.d.ts +4 -0
- package/dist/utilities/transform.d.ts.map +1 -1
- package/dist/utilities/transform.js +4 -1
- package/dist/utilities/transform.js.map +1 -1
- package/package.json +8 -3
package/dist/findGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { FindGlobal } from 'payload'\n\nimport { combineQueries } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: MongooseAdapter,\n { slug: globalSlug, locale, req, select, where = {} },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug })\n\n const fields = globalConfig.flattenedFields\n const
|
|
1
|
+
{"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { QueryOptions } from 'mongoose'\nimport type { FindGlobal } from 'payload'\n\nimport { combineQueries } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: MongooseAdapter,\n { slug: globalSlug, locale, req, select, where = {} },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug })\n\n const fields = globalConfig.flattenedFields\n\n const query = await buildQuery({\n adapter: this,\n fields,\n globalSlug,\n locale,\n where: combineQueries({ globalType: { equals: globalSlug } }, where),\n })\n\n const options: QueryOptions = {\n lean: true,\n select: buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n }),\n session: await getSession(this, req),\n }\n\n const doc: any = await Model.findOne(query, {}, options)\n\n if (!doc) {\n return null\n }\n\n transform({\n adapter: this,\n data: doc,\n fields: globalConfig.fields,\n operation: 'read',\n })\n\n return doc\n}\n"],"names":["combineQueries","buildQuery","buildProjectionFromSelect","getGlobal","getSession","transform","findGlobal","slug","globalSlug","locale","req","select","where","globalConfig","Model","adapter","fields","flattenedFields","query","globalType","equals","options","lean","session","doc","findOne","data","operation"],"mappings":"AAGA,SAASA,cAAc,QAAQ,UAAS;AAIxC,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,MAAMC,UAAU,EAAEC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,QAAQ,CAAC,CAAC,EAAE;IAErD,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGX,UAAU;QAAEY,SAAS,IAAI;QAAEP;IAAW;IAEtE,MAAMQ,SAASH,aAAaI,eAAe;IAE3C,MAAMC,QAAQ,MAAMjB,WAAW;QAC7Bc,SAAS,IAAI;QACbC;QACAR;QACAC;QACAG,OAAOZ,eAAe;YAAEmB,YAAY;gBAAEC,QAAQZ;YAAW;QAAE,GAAGI;IAChE;IAEA,MAAMS,UAAwB;QAC5BC,MAAM;QACNX,QAAQT,0BAA0B;YAChCa,SAAS,IAAI;YACbC;YACAL;QACF;QACAY,SAAS,MAAMnB,WAAW,IAAI,EAAEM;IAClC;IAEA,MAAMc,MAAW,MAAMV,MAAMW,OAAO,CAACP,OAAO,CAAC,GAAGG;IAEhD,IAAI,CAACG,KAAK;QACR,OAAO;IACT;IAEAnB,UAAU;QACRU,SAAS,IAAI;QACbW,MAAMF;QACNR,QAAQH,aAAaG,MAAM;QAC3BW,WAAW;IACb;IAEA,OAAOH;AACT,EAAC"}
|
|
@@ -12,12 +12,6 @@ export const findGlobalVersions = async function findGlobalVersions({ global: gl
|
|
|
12
12
|
versions: true
|
|
13
13
|
});
|
|
14
14
|
const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true);
|
|
15
|
-
const session = await getSession(this, req);
|
|
16
|
-
const options = {
|
|
17
|
-
limit,
|
|
18
|
-
session,
|
|
19
|
-
skip
|
|
20
|
-
};
|
|
21
15
|
let hasNearConstraint = false;
|
|
22
16
|
if (where) {
|
|
23
17
|
const constraints = flattenWhereToOperators(where);
|
|
@@ -40,6 +34,12 @@ export const findGlobalVersions = async function findGlobalVersions({ global: gl
|
|
|
40
34
|
locale,
|
|
41
35
|
where
|
|
42
36
|
});
|
|
37
|
+
const session = await getSession(this, req);
|
|
38
|
+
const options = {
|
|
39
|
+
limit,
|
|
40
|
+
session,
|
|
41
|
+
skip
|
|
42
|
+
};
|
|
43
43
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
44
44
|
const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0;
|
|
45
45
|
const paginationOptions = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindGlobalVersions } from 'payload'\n\nimport { APIError, buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global: globalSlug,\n limit = 0,\n locale,\n page,\n pagination,\n req,\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug, versions: true })\n\n const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n\n
|
|
1
|
+
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindGlobalVersions } from 'payload'\n\nimport { APIError, buildVersionGlobalFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: MongooseAdapter,\n {\n global: globalSlug,\n limit = 0,\n locale,\n page,\n pagination,\n req,\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug, versions: true })\n\n const versionFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\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 adapter: this,\n config: this.payload.config,\n fields: versionFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const query = await buildQuery({\n adapter: this,\n fields: versionFields,\n locale,\n where,\n })\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\n skip,\n }\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({ adapter: this, fields: versionFields, select }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n hint: { _id: 1 },\n session,\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionGlobalFields(this.payload.config, globalConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionGlobalFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getGlobal","getSession","transform","findGlobalVersions","global","globalSlug","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","globalConfig","Model","adapter","versions","versionFields","payload","config","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","timestamps","query","session","options","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAAmBA,wBAAwB,EAAEC,uBAAuB,QAAQ,UAAS;AAIrF,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,QAAQC,UAAU,EAClBC,QAAQ,CAAC,EACTC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,MAAMC,OAAO,EACbC,QAAQ,CAAC,CAAC,EACX;IAED,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGjB,UAAU;QAAEkB,SAAS,IAAI;QAAEb;QAAYc,UAAU;IAAK;IAEtF,MAAMC,gBAAgBzB,yBAAyB,IAAI,CAAC0B,OAAO,CAACC,MAAM,EAAEN,cAAc;IAElF,IAAIO,oBAAoB;IAExB,IAAIR,OAAO;QACT,MAAMS,cAAc5B,wBAAwBmB;QAC5CQ,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIhB;IACJ,IAAI,CAACU,mBAAmB;QACtBV,OAAOf,eAAe;YACpBoB,SAAS,IAAI;YACbI,QAAQ,IAAI,CAACD,OAAO,CAACC,MAAM;YAC3BQ,QA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AAMjC,MAAMkC,QAAQ,CAACnB,OAAOK;IAE3CnC,UAAU;QACRgB,SAAS,IAAI;QACbkC,MAAMF,OAAOG,IAAI;QACjBvB,QAAQnC,yBAAyB,IAAI,CAAC0B,OAAO,CAACC,MAAM,EAAEN;QACtDsC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
|
package/dist/findOne.js
CHANGED
|
@@ -11,11 +11,6 @@ export const findOne = async function findOne({ collection: collectionSlug, draf
|
|
|
11
11
|
adapter: this,
|
|
12
12
|
collectionSlug
|
|
13
13
|
});
|
|
14
|
-
const session = await getSession(this, req);
|
|
15
|
-
const options = {
|
|
16
|
-
lean: true,
|
|
17
|
-
session
|
|
18
|
-
};
|
|
19
14
|
const query = await buildQuery({
|
|
20
15
|
adapter: this,
|
|
21
16
|
collectionSlug,
|
|
@@ -38,6 +33,11 @@ export const findOne = async function findOne({ collection: collectionSlug, draf
|
|
|
38
33
|
projection,
|
|
39
34
|
query
|
|
40
35
|
});
|
|
36
|
+
const session = await getSession(this, req);
|
|
37
|
+
const options = {
|
|
38
|
+
lean: true,
|
|
39
|
+
session
|
|
40
|
+
};
|
|
41
41
|
let doc;
|
|
42
42
|
if (aggregate) {
|
|
43
43
|
const { docs } = await aggregatePaginate({
|
package/dist/findOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { AggregateOptions, QueryOptions } from 'mongoose'\n\nimport { type FindOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { aggregatePaginate } from './utilities/aggregatePaginate.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { resolveJoins } from './utilities/resolveJoins.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findOne: FindOne = async function findOne(\n this: MongooseAdapter,\n { collection: collectionSlug, draftsEnabled, joins, locale, req, select, where = {} },\n) {\n const { collectionConfig, Model } = getCollection({ adapter: this, collectionSlug })\n\n const
|
|
1
|
+
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { AggregateOptions, QueryOptions } from 'mongoose'\n\nimport { type FindOne } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { aggregatePaginate } from './utilities/aggregatePaginate.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { resolveJoins } from './utilities/resolveJoins.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findOne: FindOne = async function findOne(\n this: MongooseAdapter,\n { collection: collectionSlug, draftsEnabled, joins, locale, req, select, where = {} },\n) {\n const { collectionConfig, Model } = getCollection({ adapter: this, collectionSlug })\n\n const query = await buildQuery({\n adapter: this,\n collectionSlug,\n fields: collectionConfig.flattenedFields,\n locale,\n where,\n })\n\n const projection = buildProjectionFromSelect({\n adapter: this,\n fields: collectionConfig.flattenedFields,\n select,\n })\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection: collectionSlug,\n collectionConfig,\n draftsEnabled,\n joins,\n locale,\n projection,\n query,\n })\n\n const session = await getSession(this, req)\n const options: AggregateOptions & QueryOptions = {\n lean: true,\n session,\n }\n\n let doc\n if (aggregate) {\n const { docs } = await aggregatePaginate({\n adapter: this,\n joinAggregation: aggregate,\n limit: 1,\n Model,\n pagination: false,\n projection,\n query,\n session,\n })\n doc = docs[0]\n } else {\n ;(options as Record<string, unknown>).projection = projection\n doc = await Model.findOne(query, {}, options)\n }\n\n if (doc && !this.useJoinAggregations) {\n await resolveJoins({\n adapter: this,\n collectionSlug,\n docs: [doc] as Record<string, unknown>[],\n joins,\n locale,\n })\n }\n\n if (!doc) {\n return null\n }\n\n transform({ adapter: this, data: doc, fields: collectionConfig.fields, operation: 'read' })\n\n return doc\n}\n"],"names":["buildQuery","aggregatePaginate","buildJoinAggregation","buildProjectionFromSelect","getCollection","getSession","resolveJoins","transform","findOne","collection","collectionSlug","draftsEnabled","joins","locale","req","select","where","collectionConfig","Model","adapter","query","fields","flattenedFields","projection","aggregate","session","options","lean","doc","docs","joinAggregation","limit","pagination","useJoinAggregations","data","operation"],"mappings":"AAMA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,UAAmB,eAAeA,QAE7C,EAAEC,YAAYC,cAAc,EAAEC,aAAa,EAAEC,KAAK,EAAEC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,QAAQ,CAAC,CAAC,EAAE;IAErF,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGd,cAAc;QAAEe,SAAS,IAAI;QAAET;IAAe;IAElF,MAAMU,QAAQ,MAAMpB,WAAW;QAC7BmB,SAAS,IAAI;QACbT;QACAW,QAAQJ,iBAAiBK,eAAe;QACxCT;QACAG;IACF;IAEA,MAAMO,aAAapB,0BAA0B;QAC3CgB,SAAS,IAAI;QACbE,QAAQJ,iBAAiBK,eAAe;QACxCP;IACF;IAEA,MAAMS,YAAY,MAAMtB,qBAAqB;QAC3CiB,SAAS,IAAI;QACbV,YAAYC;QACZO;QACAN;QACAC;QACAC;QACAU;QACAH;IACF;IAEA,MAAMK,UAAU,MAAMpB,WAAW,IAAI,EAAES;IACvC,MAAMY,UAA2C;QAC/CC,MAAM;QACNF;IACF;IAEA,IAAIG;IACJ,IAAIJ,WAAW;QACb,MAAM,EAAEK,IAAI,EAAE,GAAG,MAAM5B,kBAAkB;YACvCkB,SAAS,IAAI;YACbW,iBAAiBN;YACjBO,OAAO;YACPb;YACAc,YAAY;YACZT;YACAH;YACAK;QACF;QACAG,MAAMC,IAAI,CAAC,EAAE;IACf,OAAO;;QACHH,QAAoCH,UAAU,GAAGA;QACnDK,MAAM,MAAMV,MAAMV,OAAO,CAACY,OAAO,CAAC,GAAGM;IACvC;IAEA,IAAIE,OAAO,CAAC,IAAI,CAACK,mBAAmB,EAAE;QACpC,MAAM3B,aAAa;YACjBa,SAAS,IAAI;YACbT;YACAmB,MAAM;gBAACD;aAAI;YACXhB;YACAC;QACF;IACF;IAEA,IAAI,CAACe,KAAK;QACR,OAAO;IACT;IAEArB,UAAU;QAAEY,SAAS,IAAI;QAAEe,MAAMN;QAAKP,QAAQJ,iBAAiBI,MAAM;QAAEc,WAAW;IAAO;IAEzF,OAAOP;AACT,EAAC"}
|
package/dist/findVersions.js
CHANGED
|
@@ -11,12 +11,6 @@ export const findVersions = async function findVersions({ collection: collection
|
|
|
11
11
|
collectionSlug,
|
|
12
12
|
versions: true
|
|
13
13
|
});
|
|
14
|
-
const session = await getSession(this, req);
|
|
15
|
-
const options = {
|
|
16
|
-
limit,
|
|
17
|
-
session,
|
|
18
|
-
skip
|
|
19
|
-
};
|
|
20
14
|
let hasNearConstraint = false;
|
|
21
15
|
if (where) {
|
|
22
16
|
const constraints = flattenWhereToOperators(where);
|
|
@@ -40,6 +34,12 @@ export const findVersions = async function findVersions({ collection: collection
|
|
|
40
34
|
locale,
|
|
41
35
|
where
|
|
42
36
|
});
|
|
37
|
+
const session = await getSession(this, req);
|
|
38
|
+
const options = {
|
|
39
|
+
limit,
|
|
40
|
+
session,
|
|
41
|
+
skip
|
|
42
|
+
};
|
|
43
43
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
44
44
|
const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0;
|
|
45
45
|
const paginationOptions = {
|
package/dist/findVersions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindVersions } from 'payload'\n\nimport { buildVersionCollectionFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n limit = 0,\n locale,\n page,\n pagination,\n req = {},\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n
|
|
1
|
+
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { PaginateOptions, QueryOptions } from 'mongoose'\nimport type { FindVersions } from 'payload'\n\nimport { buildVersionCollectionFields, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n limit = 0,\n locale,\n page,\n pagination,\n req = {},\n select,\n skip,\n sort: sortArg,\n where = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n let hasNearConstraint = false\n\n if (where) {\n const constraints = flattenWhereToOperators(where)\n hasNearConstraint = constraints.some((prop) => Object.keys(prop).some((key) => key === 'near'))\n }\n\n let sort\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n locale,\n sort: sortArg || '-updatedAt',\n timestamps: true,\n })\n }\n\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const query = await buildQuery({\n adapter: this,\n fields,\n locale,\n where,\n })\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n limit,\n session,\n skip,\n }\n\n // useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.\n const useEstimatedCount = hasNearConstraint || !query || Object.keys(query).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n limit,\n options,\n page,\n pagination,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n }),\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (!useEstimatedCount && Object.keys(query).length === 0 && this.disableIndexHints !== true) {\n // Improve the performance of the countDocuments query which is used if useEstimatedCount is set to false by adding\n // a hint. By default, if no hint is provided, MongoDB does not use an indexed field to count the returned documents,\n // which makes queries very slow. This only happens when no query (filter) is provided. If one is provided, it uses\n // the correct indexed field\n paginationOptions.useCustomCountFn = () => {\n return Promise.resolve(\n Model.countDocuments(query, {\n hint: { _id: 1 },\n session,\n }),\n )\n }\n }\n\n if (limit >= 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n\n // Disable pagination if limit is 0\n if (limit === 0) {\n paginationOptions.pagination = false\n }\n }\n\n const result = await Model.paginate(query, paginationOptions)\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig),\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildVersionCollectionFields","flattenWhereToOperators","buildQuery","buildSortParam","buildProjectionFromSelect","getCollection","getSession","transform","findVersions","collection","collectionSlug","limit","locale","page","pagination","req","select","skip","sort","sortArg","where","collectionConfig","Model","adapter","versions","hasNearConstraint","constraints","some","prop","Object","keys","key","config","payload","fields","flattenedFields","timestamps","query","session","options","useEstimatedCount","length","paginationOptions","lean","leanWithId","projection","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","paginate","data","docs","operation"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,uBAAuB,QAAQ,UAAS;AAI/E,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,YAAYC,cAAc,EAC1BC,QAAQ,CAAC,EACTC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAC,EACRC,MAAM,EACNC,IAAI,EACJC,MAAMC,OAAO,EACbC,QAAQ,CAAC,CAAC,EACX;IAED,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGjB,cAAc;QAChDkB,SAAS,IAAI;QACbb;QACAc,UAAU;IACZ;IAEA,IAAIC,oBAAoB;IAExB,IAAIL,OAAO;QACT,MAAMM,cAAczB,wBAAwBmB;QAC5CK,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,IAAIb;IACJ,IAAI,CAACO,mBAAmB;QACtBP,OAAOf,eAAe;YACpBoB,SAAS,IAAI;YACbS,QAAQ,IAAI,CA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GAAGA;QAEnC,mCAAmC;QACnC,IAAIA,UAAU,GAAG;YACf+B,kBAAkB5B,UAAU,GAAG;QACjC;IACF;IAEA,MAAMyC,SAAS,MAAMjC,MAAMkC,QAAQ,CAACnB,OAAOK;IAE3CnC,UAAU;QACRgB,SAAS,IAAI;QACbkC,MAAMF,OAAOG,IAAI;QACjBxB,QAAQlC,6BAA6B,IAAI,CAACiC,OAAO,CAACD,MAAM,EAAEX;QAC1DsC,WAAW;IACb;IAEA,OAAOJ;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAgB1C,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"queryDrafts.d.ts","sourceRoot":"","sources":["../src/queryDrafts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAgB1C,eAAO,MAAM,WAAW,EAAE,WA2KzB,CAAA"}
|
package/dist/queryDrafts.js
CHANGED
|
@@ -14,9 +14,6 @@ export const queryDrafts = async function queryDrafts({ collection: collectionSl
|
|
|
14
14
|
collectionSlug,
|
|
15
15
|
versions: true
|
|
16
16
|
});
|
|
17
|
-
const options = {
|
|
18
|
-
session: await getSession(this, req)
|
|
19
|
-
};
|
|
20
17
|
let hasNearConstraint;
|
|
21
18
|
let sort;
|
|
22
19
|
if (where) {
|
|
@@ -53,6 +50,10 @@ export const queryDrafts = async function queryDrafts({ collection: collectionSl
|
|
|
53
50
|
fields,
|
|
54
51
|
select
|
|
55
52
|
});
|
|
53
|
+
const session = await getSession(this, req);
|
|
54
|
+
const options = {
|
|
55
|
+
session
|
|
56
|
+
};
|
|
56
57
|
// useEstimatedCount is faster, but not accurate, as it ignores any filters. It is thus set to true if there are no filters.
|
|
57
58
|
const useEstimatedCount = hasNearConstraint || !versionQuery || Object.keys(versionQuery).length === 0;
|
|
58
59
|
const paginationOptions = {
|
package/dist/queryDrafts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PaginateOptions, PipelineStage, QueryOptions } from 'mongoose'\nimport type { QueryDrafts } from 'payload'\n\nimport { buildVersionCollectionFields, combineQueries, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { aggregatePaginate } from './utilities/aggregatePaginate.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { resolveJoins } from './utilities/resolveJoins.js'\nimport { transform } from './utilities/transform.js'\n\nexport const queryDrafts: QueryDrafts = async function queryDrafts(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n joins,\n limit,\n locale,\n page,\n pagination,\n req,\n select,\n sort: sortArg,\n where = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n
|
|
1
|
+
{"version":3,"sources":["../src/queryDrafts.ts"],"sourcesContent":["import type { PaginateOptions, PipelineStage, QueryOptions } from 'mongoose'\nimport type { QueryDrafts } from 'payload'\n\nimport { buildVersionCollectionFields, combineQueries, flattenWhereToOperators } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { aggregatePaginate } from './utilities/aggregatePaginate.js'\nimport { buildJoinAggregation } from './utilities/buildJoinAggregation.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { resolveJoins } from './utilities/resolveJoins.js'\nimport { transform } from './utilities/transform.js'\n\nexport const queryDrafts: QueryDrafts = async function queryDrafts(\n this: MongooseAdapter,\n {\n collection: collectionSlug,\n joins,\n limit,\n locale,\n page,\n pagination,\n req,\n select,\n sort: sortArg,\n where = {},\n },\n) {\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug,\n versions: true,\n })\n\n let hasNearConstraint\n let sort\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 fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const sortAggregation: PipelineStage[] = []\n if (!hasNearConstraint) {\n sort = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields,\n locale,\n sort: sortArg || collectionConfig.defaultSort,\n sortAggregation,\n timestamps: true,\n versions: true,\n })\n }\n\n const combinedWhere = combineQueries({ latest: { equals: true } }, where)\n\n const versionQuery = await buildQuery({\n adapter: this,\n fields,\n locale,\n where: combinedWhere,\n })\n\n const projection = buildProjectionFromSelect({\n adapter: this,\n fields,\n select,\n })\n\n const session = await getSession(this, req)\n const options: QueryOptions = {\n session,\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 =\n hasNearConstraint || !versionQuery || Object.keys(versionQuery).length === 0\n const paginationOptions: PaginateOptions = {\n lean: true,\n leanWithId: true,\n options,\n page,\n pagination,\n projection,\n sort,\n useEstimatedCount,\n }\n\n if (this.collation) {\n const defaultLocale = 'en'\n paginationOptions.collation = {\n locale: locale && locale !== 'all' && locale !== '*' ? locale : defaultLocale,\n ...this.collation,\n }\n }\n\n if (\n !useEstimatedCount &&\n Object.keys(versionQuery).length === 0 &&\n this.disableIndexHints !== true\n ) {\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(versionQuery, {\n hint: { _id: 1 },\n }),\n )\n }\n }\n\n if (limit && limit > 0) {\n paginationOptions.limit = limit\n // limit must also be set here, it's ignored when pagination is false\n\n paginationOptions.options!.limit = limit\n }\n\n let result\n\n const aggregate = await buildJoinAggregation({\n adapter: this,\n collection: collectionSlug,\n collectionConfig,\n joins,\n locale,\n projection,\n query: versionQuery,\n versions: true,\n })\n\n // build join aggregation\n if (aggregate || sortAggregation.length > 0) {\n result = await aggregatePaginate({\n adapter: this,\n collation: paginationOptions.collation,\n joinAggregation: aggregate,\n limit: paginationOptions.limit,\n Model,\n page: paginationOptions.page,\n pagination: paginationOptions.pagination,\n projection: paginationOptions.projection,\n query: versionQuery,\n session: paginationOptions.options?.session ?? undefined,\n sort: paginationOptions.sort as object,\n sortAggregation,\n useEstimatedCount: paginationOptions.useEstimatedCount,\n })\n } else {\n result = await Model.paginate(versionQuery, paginationOptions)\n }\n\n if (!this.useJoinAggregations) {\n await resolveJoins({\n adapter: this,\n collectionSlug,\n docs: result.docs as Record<string, unknown>[],\n joins,\n locale,\n versions: true,\n })\n }\n\n transform({\n adapter: this,\n data: result.docs,\n fields: buildVersionCollectionFields(this.payload.config, collectionConfig),\n operation: 'read',\n })\n\n for (let i = 0; i < result.docs.length; i++) {\n const id = result.docs[i].parent\n result.docs[i] = result.docs[i].version ?? {}\n result.docs[i].id = id\n }\n\n return result\n}\n"],"names":["buildVersionCollectionFields","combineQueries","flattenWhereToOperators","buildQuery","buildSortParam","aggregatePaginate","buildJoinAggregation","buildProjectionFromSelect","getCollection","getSession","resolveJoins","transform","queryDrafts","collection","collectionSlug","joins","limit","locale","page","pagination","req","select","sort","sortArg","where","collectionConfig","Model","adapter","versions","hasNearConstraint","constraints","some","prop","Object","keys","key","fields","payload","config","sortAggregation","defaultSort","timestamps","combinedWhere","latest","equals","versionQuery","projection","session","options","useEstimatedCount","length","paginationOptions","lean","leanWithId","collation","defaultLocale","disableIndexHints","useCustomCountFn","Promise","resolve","countDocuments","hint","_id","result","aggregate","query","joinAggregation","undefined","paginate","useJoinAggregations","docs","data","operation","i","id","parent","version"],"mappings":"AAGA,SAASA,4BAA4B,EAAEC,cAAc,EAAEC,uBAAuB,QAAQ,UAAS;AAI/F,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,iBAAiB,QAAQ,mCAAkC;AACpE,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,cAA2B,eAAeA,YAErD,EACEC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,GAAG,EACHC,MAAM,EACNC,MAAMC,OAAO,EACbC,QAAQ,CAAC,CAAC,EACX;IAED,MAAM,EAAEC,gBAAgB,EAAEC,KAAK,EAAE,GAAGlB,cAAc;QAChDmB,SAAS,IAAI;QACbb;QACAc,UAAU;IACZ;IAEA,IAAIC;IACJ,IAAIP;IAEJ,IAAIE,OAAO;QACT,MAAMM,cAAc5B,wBAAwBsB;QAC5CK,oBAAoBC,YAAYC,IAAI,CAAC,CAACC,OAASC,OAAOC,IAAI,CAACF,MAAMD,IAAI,CAAC,CAACI,MAAQA,QAAQ;IACzF;IAEA,MAAMC,SAASpC,6BAA6B,IAAI,CAACqC,OAAO,CAACC,MAAM,EAAEb,kBAAkB;IAEnF,MAAMc,kBAAmC,EAAE;IAC3C,IAAI,CAACV,mBAAmB;QACtBP,OAAOlB,eAAe;YACpBuB,SAAS,IAAI;YACbW,QAAQ,IAAI,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cb,OAAOO,IAAI,CAACG,EAAE,CAACC,EAAE,GAAGA;IACtB;IAEA,OAAOX;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAIhD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAIhD,eAAO,MAAM,iBAAiB,EAAE,iBA4B/B,CAAA"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
export const commitTransaction = async function commitTransaction(
|
|
2
|
-
|
|
1
|
+
export const commitTransaction = async function commitTransaction(incomingID = '') {
|
|
2
|
+
const transactionID = incomingID instanceof Promise ? await incomingID : incomingID;
|
|
3
|
+
if (!this.sessions[transactionID]) {
|
|
3
4
|
return;
|
|
4
5
|
}
|
|
5
|
-
if (!this.sessions[
|
|
6
|
+
if (!this.sessions[transactionID]?.inTransaction()) {
|
|
7
|
+
// Clean up the orphaned session reference
|
|
8
|
+
delete this.sessions[transactionID];
|
|
6
9
|
return;
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
const session = this.sessions[transactionID];
|
|
12
|
+
// Delete from registry FIRST to prevent race conditions
|
|
13
|
+
// This ensures other operations can't retrieve this session while we're ending it
|
|
14
|
+
delete this.sessions[transactionID];
|
|
15
|
+
await session.commitTransaction();
|
|
9
16
|
try {
|
|
10
|
-
await
|
|
17
|
+
await session.endSession();
|
|
11
18
|
} catch (_) {
|
|
12
19
|
// ending sessions is only best effort and won't impact anything if it fails since the transaction was committed
|
|
13
20
|
}
|
|
14
|
-
delete this.sessions[id];
|
|
15
21
|
};
|
|
16
22
|
|
|
17
23
|
//# sourceMappingURL=commitTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(\n this: MongooseAdapter,\n
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(\n this: MongooseAdapter,\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n if (!this.sessions[transactionID]) {\n return\n }\n\n if (!this.sessions[transactionID]?.inTransaction()) {\n // Clean up the orphaned session reference\n delete this.sessions[transactionID]\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n await session.commitTransaction()\n try {\n await session.endSession()\n } catch (_) {\n // ending sessions is only best effort and won't impact anything if it fails since the transaction was committed\n }\n}\n"],"names":["commitTransaction","incomingID","transactionID","Promise","sessions","inTransaction","session","endSession","_"],"mappings":"AAIA,OAAO,MAAMA,oBAAuC,eAAeA,kBAEjEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,IAAI,CAAC,IAAI,CAACE,QAAQ,CAACF,cAAc,EAAEG,iBAAiB;QAClD,0CAA0C;QAC1C,OAAO,IAAI,CAACD,QAAQ,CAACF,cAAc;QACnC;IACF;IAEA,MAAMI,UAAU,IAAI,CAACF,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,kFAAkF;IAClF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,MAAMI,QAAQN,iBAAiB;IAC/B,IAAI;QACF,MAAMM,QAAQC,UAAU;IAC1B,EAAE,OAAOC,GAAG;IACV,gHAAgH;IAClH;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,eAAO,MAAM,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"rollbackTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/rollbackTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAIlD,eAAO,MAAM,mBAAmB,EAAE,mBAgCjC,CAAA"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
export const rollbackTransaction = async function rollbackTransaction(incomingID = '') {
|
|
2
|
-
|
|
3
|
-
if (incomingID instanceof Promise) {
|
|
4
|
-
transactionID = await incomingID;
|
|
5
|
-
} else {
|
|
6
|
-
transactionID = incomingID;
|
|
7
|
-
}
|
|
2
|
+
const transactionID = incomingID instanceof Promise ? await incomingID : incomingID;
|
|
8
3
|
// if multiple operations are using the same transaction, the first will flow through and delete the session.
|
|
9
4
|
// subsequent calls should be ignored.
|
|
10
5
|
if (!this.sessions[transactionID]) {
|
|
@@ -16,14 +11,17 @@ export const rollbackTransaction = async function rollbackTransaction(incomingID
|
|
|
16
11
|
delete this.sessions[transactionID];
|
|
17
12
|
return;
|
|
18
13
|
}
|
|
14
|
+
const session = this.sessions[transactionID];
|
|
15
|
+
// Delete from registry FIRST to prevent race conditions
|
|
16
|
+
// This ensures other operations can't retrieve this session while we're aborting it
|
|
17
|
+
delete this.sessions[transactionID];
|
|
19
18
|
// the first call for rollback should be aborted and deleted causing any other operations with the same transaction to fail
|
|
20
19
|
try {
|
|
21
|
-
await
|
|
22
|
-
await
|
|
23
|
-
} catch (
|
|
20
|
+
await session.abortTransaction();
|
|
21
|
+
await session.endSession();
|
|
22
|
+
} catch (_error) {
|
|
24
23
|
// ignore the error as it is likely a race condition from multiple errors
|
|
25
24
|
}
|
|
26
|
-
delete this.sessions[transactionID];
|
|
27
25
|
};
|
|
28
26
|
|
|
29
27
|
//# sourceMappingURL=rollbackTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n this: MongooseAdapter,\n incomingID = '',\n) {\n
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/rollbackTransaction.ts"],"sourcesContent":["import type { RollbackTransaction } from 'payload'\n\nimport type { MongooseAdapter } from '../index.js'\n\nexport const rollbackTransaction: RollbackTransaction = async function rollbackTransaction(\n this: MongooseAdapter,\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if multiple operations are using the same transaction, the first will flow through and delete the session.\n // subsequent calls should be ignored.\n if (!this.sessions[transactionID]) {\n return\n }\n\n // when session exists but is not inTransaction something unexpected is happening to the session\n if (!this.sessions[transactionID]?.inTransaction()) {\n this.payload.logger.warn('rollbackTransaction called when no transaction exists')\n delete this.sessions[transactionID]\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're aborting it\n delete this.sessions[transactionID]\n\n // the first call for rollback should be aborted and deleted causing any other operations with the same transaction to fail\n try {\n await session.abortTransaction()\n await session.endSession()\n } catch (_error) {\n // ignore the error as it is likely a race condition from multiple errors\n }\n}\n"],"names":["rollbackTransaction","incomingID","transactionID","Promise","sessions","inTransaction","payload","logger","warn","session","abortTransaction","endSession","_error"],"mappings":"AAIA,OAAO,MAAMA,sBAA2C,eAAeA,oBAErEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,6GAA6G;IAC7G,sCAAsC;IACtC,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,gGAAgG;IAChG,IAAI,CAAC,IAAI,CAACE,QAAQ,CAACF,cAAc,EAAEG,iBAAiB;QAClD,IAAI,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC;QACzB,OAAO,IAAI,CAACJ,QAAQ,CAACF,cAAc;QACnC;IACF;IAEA,MAAMO,UAAU,IAAI,CAACL,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,oFAAoF;IACpF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,2HAA2H;IAC3H,IAAI;QACF,MAAMO,QAAQC,gBAAgB;QAC9B,MAAMD,QAAQE,UAAU;IAC1B,EAAE,OAAOC,QAAQ;IACf,yEAAyE;IAC3E;AACF,EAAC"}
|
package/dist/updateGlobal.js
CHANGED
|
@@ -8,6 +8,13 @@ export const updateGlobal = async function updateGlobal({ slug: globalSlug, data
|
|
|
8
8
|
globalSlug
|
|
9
9
|
});
|
|
10
10
|
const fields = globalConfig.fields;
|
|
11
|
+
transform({
|
|
12
|
+
adapter: this,
|
|
13
|
+
data,
|
|
14
|
+
fields,
|
|
15
|
+
globalSlug,
|
|
16
|
+
operation: 'write'
|
|
17
|
+
});
|
|
11
18
|
const options = {
|
|
12
19
|
...optionsArgs,
|
|
13
20
|
lean: true,
|
|
@@ -21,13 +28,6 @@ export const updateGlobal = async function updateGlobal({ slug: globalSlug, data
|
|
|
21
28
|
// Timestamps are manually added by the write transform
|
|
22
29
|
timestamps: false
|
|
23
30
|
};
|
|
24
|
-
transform({
|
|
25
|
-
adapter: this,
|
|
26
|
-
data,
|
|
27
|
-
fields,
|
|
28
|
-
globalSlug,
|
|
29
|
-
operation: 'write'
|
|
30
|
-
});
|
|
31
31
|
if (returning === false) {
|
|
32
32
|
await Model.updateOne({
|
|
33
33
|
globalType: globalSlug
|
package/dist/updateGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\nimport type { UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug: globalSlug, data, options: optionsArgs = {}, req, returning, select },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug })\n\n const fields = globalConfig.fields\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: globalConfig.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\nimport type { UpdateGlobal } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateGlobal: UpdateGlobal = async function updateGlobal(\n this: MongooseAdapter,\n { slug: globalSlug, data, options: optionsArgs = {}, req, returning, select },\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug })\n\n const fields = globalConfig.fields\n\n transform({ adapter: this, data, fields, globalSlug, operation: 'write' })\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: globalConfig.flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n if (returning === false) {\n await Model.updateOne({ globalType: globalSlug }, data, options)\n return null\n }\n\n const result: any = await Model.findOneAndUpdate({ globalType: globalSlug }, data, options)\n\n transform({ adapter: this, data: result, fields, globalSlug, operation: 'read' })\n\n return result\n}\n"],"names":["buildProjectionFromSelect","getGlobal","getSession","transform","updateGlobal","slug","globalSlug","data","options","optionsArgs","req","returning","select","globalConfig","Model","adapter","fields","operation","lean","new","projection","flattenedFields","session","timestamps","updateOne","globalType","result","findOneAndUpdate"],"mappings":"AAKA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,2BAA0B;AACpD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EAAEC,MAAMC,UAAU,EAAEC,IAAI,EAAEC,SAASC,cAAc,CAAC,CAAC,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAM,EAAE;IAE7E,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGb,UAAU;QAAEc,SAAS,IAAI;QAAET;IAAW;IAEtE,MAAMU,SAASH,aAAaG,MAAM;IAElCb,UAAU;QAAEY,SAAS,IAAI;QAAER;QAAMS;QAAQV;QAAYW,WAAW;IAAQ;IAExE,MAAMT,UAAsC;QAC1C,GAAGC,WAAW;QACdS,MAAM;QACNC,KAAK;QACLC,YAAYpB,0BAA0B;YACpCe,SAAS,IAAI;YACbC,QAAQH,aAAaQ,eAAe;YACpCT;QACF;QACAU,SAAS,MAAMpB,WAAW,IAAI,EAAEQ;QAChC,uDAAuD;QACvDa,YAAY;IACd;IAEA,IAAIZ,cAAc,OAAO;QACvB,MAAMG,MAAMU,SAAS,CAAC;YAAEC,YAAYnB;QAAW,GAAGC,MAAMC;QACxD,OAAO;IACT;IAEA,MAAMkB,SAAc,MAAMZ,MAAMa,gBAAgB,CAAC;QAAEF,YAAYnB;IAAW,GAAGC,MAAMC;IAEnFL,UAAU;QAAEY,SAAS,IAAI;QAAER,MAAMmB;QAAQV;QAAQV;QAAYW,WAAW;IAAO;IAE/E,OAAOS;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAIlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAQjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EACzE,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EAAE,UAAU,EAClB,MAAM,EACN,OAAO,EAAE,WAAgB,EACzB,GAAG,EACH,SAAS,EACT,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAIlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAQjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EACzE,IAAI,EAAE,eAAe,EACrB,EACE,EAAE,EACF,MAAM,EAAE,UAAU,EAClB,MAAM,EACN,OAAO,EAAE,WAAgB,EACzB,GAAG,EACH,SAAS,EACT,MAAM,EACN,WAAW,EACX,KAAK,GACN,EAAE,uBAAuB,CAAC,CAAC,CAAC,gBA6C9B"}
|
|
@@ -17,6 +17,18 @@ export async function updateGlobalVersion({ id, global: globalSlug, locale, opti
|
|
|
17
17
|
};
|
|
18
18
|
const fields = buildVersionGlobalFields(this.payload.config, globalConfig);
|
|
19
19
|
const flattenedFields = buildVersionGlobalFields(this.payload.config, globalConfig, true);
|
|
20
|
+
const query = await buildQuery({
|
|
21
|
+
adapter: this,
|
|
22
|
+
fields: flattenedFields,
|
|
23
|
+
locale,
|
|
24
|
+
where: whereToUse
|
|
25
|
+
});
|
|
26
|
+
transform({
|
|
27
|
+
adapter: this,
|
|
28
|
+
data: versionData,
|
|
29
|
+
fields,
|
|
30
|
+
operation: 'write'
|
|
31
|
+
});
|
|
20
32
|
const options = {
|
|
21
33
|
...optionsArgs,
|
|
22
34
|
lean: true,
|
|
@@ -30,18 +42,6 @@ export async function updateGlobalVersion({ id, global: globalSlug, locale, opti
|
|
|
30
42
|
// Timestamps are manually added by the write transform
|
|
31
43
|
timestamps: false
|
|
32
44
|
};
|
|
33
|
-
const query = await buildQuery({
|
|
34
|
-
adapter: this,
|
|
35
|
-
fields: flattenedFields,
|
|
36
|
-
locale,
|
|
37
|
-
where: whereToUse
|
|
38
|
-
});
|
|
39
|
-
transform({
|
|
40
|
-
adapter: this,
|
|
41
|
-
data: versionData,
|
|
42
|
-
fields,
|
|
43
|
-
operation: 'write'
|
|
44
|
-
});
|
|
45
45
|
if (returning === false) {
|
|
46
46
|
await Model.updateOne(query, versionData, options);
|
|
47
47
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\nimport type { JsonObject, UpdateGlobalVersionArgs } from 'payload'\n\nimport { buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport async function updateGlobalVersion<T extends JsonObject = JsonObject>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug, versions: true })\n const whereToUse = where || { id: { equals: id } }\n\n const fields = buildVersionGlobalFields(this.payload.config, globalConfig)\n const flattenedFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\nimport type { JsonObject, UpdateGlobalVersionArgs } from 'payload'\n\nimport { buildVersionGlobalFields } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildProjectionFromSelect } from './utilities/buildProjectionFromSelect.js'\nimport { getGlobal } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { transform } from './utilities/transform.js'\n\nexport async function updateGlobalVersion<T extends JsonObject = JsonObject>(\n this: MongooseAdapter,\n {\n id,\n global: globalSlug,\n locale,\n options: optionsArgs = {},\n req,\n returning,\n select,\n versionData,\n where,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const { globalConfig, Model } = getGlobal({ adapter: this, globalSlug, versions: true })\n const whereToUse = where || { id: { equals: id } }\n\n const fields = buildVersionGlobalFields(this.payload.config, globalConfig)\n const flattenedFields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n\n const query = await buildQuery({\n adapter: this,\n fields: flattenedFields,\n locale,\n where: whereToUse,\n })\n\n transform({ adapter: this, data: versionData, fields, operation: 'write' })\n\n const options: MongooseUpdateQueryOptions = {\n ...optionsArgs,\n lean: true,\n new: true,\n projection: buildProjectionFromSelect({\n adapter: this,\n fields: flattenedFields,\n select,\n }),\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n if (returning === false) {\n await Model.updateOne(query, versionData, options)\n return null\n }\n\n const doc = await Model.findOneAndUpdate(query, versionData, options)\n\n if (!doc) {\n return null\n }\n\n transform({ adapter: this, data: doc, fields, operation: 'read' })\n\n return doc\n}\n"],"names":["buildVersionGlobalFields","buildQuery","buildProjectionFromSelect","getGlobal","getSession","transform","updateGlobalVersion","id","global","globalSlug","locale","options","optionsArgs","req","returning","select","versionData","where","globalConfig","Model","adapter","versions","whereToUse","equals","fields","payload","config","flattenedFields","query","data","operation","lean","new","projection","session","timestamps","updateOne","doc","findOneAndUpdate"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,UAAS;AAIlD,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,SAAS,QAAQ,2BAA0B;AACpD,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,SAAS,EACTC,MAAM,EACNC,WAAW,EACXC,KAAK,EACsB;IAE7B,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAE,GAAGhB,UAAU;QAAEiB,SAAS,IAAI;QAAEX;QAAYY,UAAU;IAAK;IACtF,MAAMC,aAAaL,SAAS;QAAEV,IAAI;YAAEgB,QAAQhB;QAAG;IAAE;IAEjD,MAAMiB,SAASxB,yBAAyB,IAAI,CAACyB,OAAO,CAACC,MAAM,EAAER;IAC7D,MAAMS,kBAAkB3B,yBAAyB,IAAI,CAACyB,OAAO,CAACC,MAAM,EAAER,cAAc;IAEpF,MAAMU,QAAQ,MAAM3B,WAAW;QAC7BmB,SAAS,IAAI;QACbI,QAAQG;QACRjB;QACAO,OAAOK;IACT;IAEAjB,UAAU;QAAEe,SAAS,IAAI;QAAES,MAAMb;QAAaQ;QAAQM,WAAW;IAAQ;IAEzE,MAAMnB,UAAsC;QAC1C,GAAGC,WAAW;QACdmB,MAAM;QACNC,KAAK;QACLC,YAAY/B,0BAA0B;YACpCkB,SAAS,IAAI;YACbI,QAAQG;YACRZ;QACF;QACAmB,SAAS,MAAM9B,WAAW,IAAI,EAAES;QAChC,uDAAuD;QACvDsB,YAAY;IACd;IAEA,IAAIrB,cAAc,OAAO;QACvB,MAAMK,MAAMiB,SAAS,CAACR,OAAOZ,aAAaL;QAC1C,OAAO;IACT;IAEA,MAAM0B,MAAM,MAAMlB,MAAMmB,gBAAgB,CAACV,OAAOZ,aAAaL;IAE7D,IAAI,CAAC0B,KAAK;QACR,OAAO;IACT;IAEAhC,UAAU;QAAEe,SAAS,IAAI;QAAES,MAAMQ;QAAKb;QAAQM,WAAW;IAAO;IAEhE,OAAOO;AACT"}
|
package/dist/updateJobs.js
CHANGED
|
@@ -24,13 +24,6 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
24
24
|
sort: sortArg || collectionConfig.defaultSort,
|
|
25
25
|
timestamps: true
|
|
26
26
|
});
|
|
27
|
-
const options = {
|
|
28
|
-
lean: true,
|
|
29
|
-
new: true,
|
|
30
|
-
session: await getSession(this, req),
|
|
31
|
-
// Timestamps are manually added by the write transform
|
|
32
|
-
timestamps: false
|
|
33
|
-
};
|
|
34
27
|
let query = await buildQuery({
|
|
35
28
|
adapter: this,
|
|
36
29
|
collectionSlug: collectionConfig.slug,
|
|
@@ -69,6 +62,13 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
69
62
|
updateOps.$set = updateData;
|
|
70
63
|
updateData = updateOps;
|
|
71
64
|
}
|
|
65
|
+
const options = {
|
|
66
|
+
lean: true,
|
|
67
|
+
new: true,
|
|
68
|
+
session: await getSession(this, req),
|
|
69
|
+
// Timestamps are manually added by the write transform
|
|
70
|
+
timestamps: false
|
|
71
|
+
};
|
|
72
72
|
let result = [];
|
|
73
73
|
try {
|
|
74
74
|
if (id) {
|
package/dist/updateJobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions, UpdateQuery } from 'mongoose'\nimport type { Job, UpdateJobs, Where } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: MongooseAdapter,\n { id, data, limit, req, returning, sort: sortArg, where: whereArg },\n) {\n if (\n !(data?.log as object[])?.length &&\n !(data.log && typeof data.log === 'object' && '$push' in data.log)\n ) {\n delete data.log\n }\n\n const where = id ? { id: { equals: id } } : (whereArg as Where)\n\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug: 'payload-jobs',\n })\n\n const sort: Record<string, unknown> | undefined = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n\n
|
|
1
|
+
{"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions, UpdateQuery } from 'mongoose'\nimport type { Job, UpdateJobs, Where } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { buildSortParam } from './queries/buildSortParam.js'\nimport { getCollection } from './utilities/getEntity.js'\nimport { getSession } from './utilities/getSession.js'\nimport { handleError } from './utilities/handleError.js'\nimport { transform } from './utilities/transform.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: MongooseAdapter,\n { id, data, limit, req, returning, sort: sortArg, where: whereArg },\n) {\n if (\n !(data?.log as object[])?.length &&\n !(data.log && typeof data.log === 'object' && '$push' in data.log)\n ) {\n delete data.log\n }\n\n const where = id ? { id: { equals: id } } : (whereArg as Where)\n\n const { collectionConfig, Model } = getCollection({\n adapter: this,\n collectionSlug: 'payload-jobs',\n })\n\n const sort: Record<string, unknown> | undefined = buildSortParam({\n adapter: this,\n config: this.payload.config,\n fields: collectionConfig.flattenedFields,\n sort: sortArg || collectionConfig.defaultSort,\n timestamps: true,\n })\n\n let query = await buildQuery({\n adapter: this,\n collectionSlug: collectionConfig.slug,\n fields: collectionConfig.flattenedFields,\n where,\n })\n\n let updateData: UpdateQuery<any> = data\n\n const $inc: Record<string, number> = {}\n const $push: Record<string, { $each: any[] } | any> = {}\n const $addToSet: Record<string, { $each: any[] } | any> = {}\n const $pull: Record<string, { $in: any[] } | any> = {}\n\n transform({\n $addToSet,\n $inc,\n $pull,\n $push,\n adapter: this,\n data,\n fields: collectionConfig.fields,\n operation: 'write',\n })\n\n const updateOps: UpdateQuery<any> = {}\n\n if (Object.keys($inc).length) {\n updateOps.$inc = $inc\n }\n if (Object.keys($push).length) {\n updateOps.$push = $push\n }\n if (Object.keys($addToSet).length) {\n updateOps.$addToSet = $addToSet\n }\n if (Object.keys($pull).length) {\n updateOps.$pull = $pull\n }\n if (Object.keys(updateOps).length) {\n updateOps.$set = updateData\n updateData = updateOps\n }\n\n const options: MongooseUpdateQueryOptions = {\n lean: true,\n new: true,\n session: await getSession(this, req),\n // Timestamps are manually added by the write transform\n timestamps: false,\n }\n\n let result: Job[] = []\n\n try {\n if (id) {\n if (returning === false) {\n await Model.updateOne(query, updateData, options)\n transform({ adapter: this, data, fields: collectionConfig.fields, operation: 'read' })\n\n return null\n } else {\n const doc = await Model.findOneAndUpdate(query, updateData, options)\n result = doc ? [doc] : []\n }\n } else {\n if (typeof limit === 'number' && limit > 0) {\n const documentsToUpdate = await Model.find(\n query,\n {},\n { ...options, limit, projection: { _id: 1 }, sort },\n )\n if (documentsToUpdate.length === 0) {\n return null\n }\n\n query = { _id: { $in: documentsToUpdate.map((doc) => doc._id) } }\n }\n\n await Model.updateMany(query, updateData, options)\n\n if (returning === false) {\n return null\n }\n\n result = await Model.find(\n query,\n {},\n {\n ...options,\n sort,\n },\n )\n }\n } catch (error) {\n handleError({ collection: collectionConfig.slug, error, req })\n }\n\n transform({\n adapter: this,\n data: result,\n fields: collectionConfig.fields,\n operation: 'read',\n })\n\n return result\n}\n"],"names":["buildQuery","buildSortParam","getCollection","getSession","handleError","transform","updateJobs","updateMany","id","data","limit","req","returning","sort","sortArg","where","whereArg","log","length","equals","collectionConfig","Model","adapter","collectionSlug","config","payload","fields","flattenedFields","defaultSort","timestamps","query","slug","updateData","$inc","$push","$addToSet","$pull","operation","updateOps","Object","keys","$set","options","lean","new","session","result","updateOne","doc","findOneAndUpdate","documentsToUpdate","find","projection","_id","$in","map","error","collection"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,WAAW,QAAQ,6BAA4B;AACxD,SAASC,SAAS,QAAQ,2BAA0B;AAEpD,OAAO,MAAMC,aAAyB,eAAeC,WAEnD,EAAEC,EAAE,EAAEC,IAAI,EAAEC,KAAK,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAMC,OAAO,EAAEC,OAAOC,QAAQ,EAAE;IAEnE,IACE,CAAEP,MAAMQ,KAAkBC,UAC1B,CAAET,CAAAA,KAAKQ,GAAG,IAAI,OAAOR,KAAKQ,GAAG,KAAK,YAAY,WAAWR,KAAKQ,GAAG,AAAD,GAChE;QACA,OAAOR,KAAKQ,GAAG;IACjB;IAEA,MAAMF,QAAQP,KAAK;QAAEA,IAAI;YAAEW,QAAQX;QAAG;IAAE,IA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