@payloadcms/db-mongodb 3.32.0-internal.3c1ca0f → 3.32.0-internal.7b8361c

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.
@@ -1 +1 @@
1
- {"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,UAAU,EAAS,MAAM,SAAS,CAAA;AAUzD,eAAO,MAAM,UAAU,EAAE,UA0ExB,CAAA"}
1
+ {"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAW,UAAU,EAAS,MAAM,SAAS,CAAA;AAWzD,eAAO,MAAM,UAAU,EAAE,UAyFxB,CAAA"}
@@ -1,9 +1,10 @@
1
1
  import { buildQuery } from './queries/buildQuery.js';
2
+ import { buildSortParam } from './queries/buildSortParam.js';
2
3
  import { getCollection } from './utilities/getEntity.js';
3
4
  import { getSession } from './utilities/getSession.js';
4
5
  import { handleError } from './utilities/handleError.js';
5
6
  import { transform } from './utilities/transform.js';
6
- export const updateJobs = async function updateMany({ id, data, limit, req, returning, where: whereArg }) {
7
+ export const updateJobs = async function updateMany({ id, data, limit, req, returning, sort: sortArg, where: whereArg }) {
7
8
  if (!data?.log?.length) {
8
9
  delete data.log;
9
10
  }
@@ -16,6 +17,13 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
16
17
  adapter: this,
17
18
  collectionSlug: 'payload-jobs'
18
19
  });
20
+ const sort = buildSortParam({
21
+ adapter: this,
22
+ config: this.payload.config,
23
+ fields: collectionConfig.flattenedFields,
24
+ sort: sortArg || collectionConfig.defaultSort,
25
+ timestamps: true
26
+ });
19
27
  const options = {
20
28
  lean: true,
21
29
  new: true,
@@ -52,7 +60,8 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
52
60
  limit,
53
61
  projection: {
54
62
  _id: 1
55
- }
63
+ },
64
+ sort
56
65
  });
57
66
  if (documentsToUpdate.length === 0) {
58
67
  return null;
@@ -67,7 +76,10 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
67
76
  if (returning === false) {
68
77
  return null;
69
78
  }
70
- result = await Model.find(query, {}, options);
79
+ result = await Model.find(query, {}, {
80
+ ...options,
81
+ sort
82
+ });
71
83
  }
72
84
  } catch (error) {
73
85
  handleError({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\nimport type { BaseJob, UpdateJobs, Where } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nimport { buildQuery } from './queries/buildQuery.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, where: whereArg },\n) {\n if (!(data?.log as object[])?.length) {\n delete data.log\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 options: MongooseUpdateQueryOptions = {\n lean: true,\n new: true,\n session: await getSession(this, req),\n }\n\n let query = await buildQuery({\n adapter: this,\n collectionSlug: collectionConfig.slug,\n fields: collectionConfig.flattenedFields,\n where,\n })\n\n transform({ adapter: this, data, fields: collectionConfig.fields, operation: 'write' })\n\n let result: BaseJob[] = []\n\n try {\n if (id) {\n if (returning === false) {\n await Model.updateOne(query, data, options)\n return null\n } else {\n const doc = await Model.findOneAndUpdate(query, data, 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 } },\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, data, options)\n\n if (returning === false) {\n return null\n }\n\n result = await Model.find(query, {}, options)\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","getCollection","getSession","handleError","transform","updateJobs","updateMany","id","data","limit","req","returning","where","whereArg","log","length","equals","collectionConfig","Model","adapter","collectionSlug","options","lean","new","session","query","slug","fields","flattenedFields","operation","result","updateOne","doc","findOneAndUpdate","documentsToUpdate","find","projection","_id","$in","map","error","collection"],"mappings":"AAKA,SAASA,UAAU,QAAQ,0BAAyB;AACpD,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,OAAOC,QAAQ,EAAE;IAEpD,IAAI,CAAEL,MAAMM,KAAkBC,QAAQ;QACpC,OAAOP,KAAKM,GAAG;IACjB;IACA,MAAMF,QAAQL,KAAK;QAAEA,IAAI;YAAES,QAAQT;QAAG;IAAE,IAAKM;IAE7C,MAAM,EAAEI,gBAAgB,EAAEC,KAAK,EAAE,GAAGjB,cAAc;QAChDkB,SAAS,IAAI;QACbC,gBAAgB;IAClB;IAEA,MAAMC,UAAsC;QAC1CC,MAAM;QACNC,KAAK;QACLC,SAAS,MAAMtB,WAAW,IAAI,EAAEQ;IAClC;IAEA,IAAIe,QAAQ,MAAMzB,WAAW;QAC3BmB,SAAS,IAAI;QACbC,gBAAgBH,iBAAiBS,IAAI;QACrCC,QAAQV,iBAAiBW,eAAe;QACxChB;IACF;IAEAR,UAAU;QAAEe,SAAS,IAAI;QAAEX;QAAMmB,QAAQV,iBAAiBU,MAAM;QAAEE,WAAW;IAAQ;IAErF,IAAIC,SAAoB,EAAE;IAE1B,IAAI;QACF,IAAIvB,IAAI;YACN,IAAII,cAAc,OAAO;gBACvB,MAAMO,MAAMa,SAAS,CAACN,OAAOjB,MAAMa;gBACnC,OAAO;YACT,OAAO;gBACL,MAAMW,MAAM,MAAMd,MAAMe,gBAAgB,CAACR,OAAOjB,MAAMa;gBACtDS,SAASE,MAAM;oBAACA;iBAAI,GAAG,EAAE;YAC3B;QACF,OAAO;YACL,IAAI,OAAOvB,UAAU,YAAYA,QAAQ,GAAG;gBAC1C,MAAMyB,oBAAoB,MAAMhB,MAAMiB,IAAI,CACxCV,OACA,CAAC,GACD;oBAAE,GAAGJ,OAAO;oBAAEZ;oBAAO2B,YAAY;wBAAEC,KAAK;oBAAE;gBAAE;gBAE9C,IAAIH,kBAAkBnB,MAAM,KAAK,GAAG;oBAClC,OAAO;gBACT;gBAEAU,QAAQ;oBAAEY,KAAK;wBAAEC,KAAKJ,kBAAkBK,GAAG,CAAC,CAACP,MAAQA,IAAIK,GAAG;oBAAE;gBAAE;YAClE;YAEA,MAAMnB,MAAMZ,UAAU,CAACmB,OAAOjB,MAAMa;YAEpC,IAAIV,cAAc,OAAO;gBACvB,OAAO;YACT;YAEAmB,SAAS,MAAMZ,MAAMiB,IAAI,CAACV,OAAO,CAAC,GAAGJ;QACvC;IACF,EAAE,OAAOmB,OAAO;QACdrC,YAAY;YAAEsC,YAAYxB,iBAAiBS,IAAI;YAAEc;YAAO9B;QAAI;IAC9D;IAEAN,UAAU;QACRe,SAAS,IAAI;QACbX,MAAMsB;QACNH,QAAQV,iBAAiBU,MAAM;QAC/BE,WAAW;IACb;IAEA,OAAOC;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { MongooseUpdateQueryOptions } from 'mongoose'\nimport type { BaseJob, 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 (!(data?.log as object[])?.length) {\n delete data.log\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 const options: MongooseUpdateQueryOptions = {\n lean: true,\n new: true,\n session: await getSession(this, req),\n }\n\n let query = await buildQuery({\n adapter: this,\n collectionSlug: collectionConfig.slug,\n fields: collectionConfig.flattenedFields,\n where,\n })\n\n transform({ adapter: this, data, fields: collectionConfig.fields, operation: 'write' })\n\n let result: BaseJob[] = []\n\n try {\n if (id) {\n if (returning === false) {\n await Model.updateOne(query, data, options)\n return null\n } else {\n const doc = await Model.findOneAndUpdate(query, data, 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, data, 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","options","lean","new","session","query","slug","operation","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,IAAI,CAAEP,MAAMQ,KAAkBC,QAAQ;QACpC,OAAOT,KAAKQ,GAAG;IACjB;IACA,MAAMF,QAAQP,KAAK;QAAEA,IAAI;YAAEW,QAAQX;QAAG;IAAE,IAAKQ;IAE7C,MAAM,EAAEI,gBAAgB,EAAEC,KAAK,EAAE,GAAGnB,cAAc;QAChDoB,SAAS,IAAI;QACbC,gBAAgB;IAClB;IAEA,MAAMV,OAA4CZ,eAAe;QAC/DqB,SAAS,IAAI;QACbE,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BE,QAAQN,iBAAiBO,eAAe;QACxCd,MAAMC,WAAWM,iBAAiBQ,WAAW;QAC7CC,YAAY;IACd;IAEA,MAAMC,UAAsC;QAC1CC,MAAM;QACNC,KAAK;QACLC,SAAS,MAAM9B,WAAW,IAAI,EAAEQ;IAClC;IAEA,IAAIuB,QAAQ,MAAMlC,WAAW;QAC3BsB,SAAS,IAAI;QACbC,gBAAgBH,iBAAiBe,IAAI;QACrCT,QAAQN,iBAAiBO,eAAe;QACxCZ;IACF;IAEAV,UAAU;QA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/db-mongodb",
3
- "version": "3.32.0-internal.3c1ca0f",
3
+ "version": "3.32.0-internal.7b8361c",
4
4
  "description": "The officially supported MongoDB database adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -49,10 +49,10 @@
49
49
  "mongodb": "6.12.0",
50
50
  "mongodb-memory-server": "^10",
51
51
  "@payloadcms/eslint-config": "3.28.0",
52
- "payload": "3.32.0-internal.3c1ca0f"
52
+ "payload": "3.32.0-internal.7b8361c"
53
53
  },
54
54
  "peerDependencies": {
55
- "payload": "3.32.0-internal.3c1ca0f"
55
+ "payload": "3.32.0-internal.7b8361c"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "pnpm build:types && pnpm build:swc",