@payloadcms/db-mongodb 3.32.0-internal.ef3356b → 3.32.0-internal.f2e77bd

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;AAWzD,eAAO,MAAM,UAAU,EAAE,UAsFxB,CAAA"}
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,UAuExB,CAAA"}
@@ -1,10 +1,9 @@
1
1
  import { buildQuery } from './queries/buildQuery.js';
2
- import { buildSortParam } from './queries/buildSortParam.js';
3
2
  import { getCollection } from './utilities/getEntity.js';
4
3
  import { getSession } from './utilities/getSession.js';
5
4
  import { handleError } from './utilities/handleError.js';
6
5
  import { transform } from './utilities/transform.js';
7
- export const updateJobs = async function updateMany({ id, data, limit, req, returning, sort: sortArg, where: whereArg }) {
6
+ export const updateJobs = async function updateMany({ id, data, limit, req, returning, where: whereArg }) {
8
7
  const where = id ? {
9
8
  id: {
10
9
  equals: id
@@ -14,13 +13,6 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
14
13
  adapter: this,
15
14
  collectionSlug: 'payload-jobs'
16
15
  });
17
- const sort = buildSortParam({
18
- adapter: this,
19
- config: this.payload.config,
20
- fields: collectionConfig.flattenedFields,
21
- sort: sortArg || collectionConfig.defaultSort,
22
- timestamps: true
23
- });
24
16
  const options = {
25
17
  lean: true,
26
18
  new: true,
@@ -57,8 +49,7 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
57
49
  limit,
58
50
  projection: {
59
51
  _id: 1
60
- },
61
- sort
52
+ }
62
53
  });
63
54
  if (documentsToUpdate.length === 0) {
64
55
  return null;
@@ -73,10 +64,7 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
73
64
  if (returning === false) {
74
65
  return null;
75
66
  }
76
- result = await Model.find(query, {}, {
77
- ...options,
78
- sort
79
- });
67
+ result = await Model.find(query, {}, options);
80
68
  }
81
69
  } catch (error) {
82
70
  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 { 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 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","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","length","$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,MAAMD,QAAQP,KAAK;QAAEA,IAAI;YAAES,QAAQT;QAAG;IAAE,IAAKQ;IAE7C,MAAM,EAAEE,gBAAgB,EAAEC,KAAK,EAAE,GAAGjB,cAAc;QAChDkB,SAAS,IAAI;QACbC,gBAAgB;IAClB;IAEA,MAAMR,OAA4CZ,eAAe;QAC/DmB,SAAS,IAAI;QACbE,QAAQ,IAAI,CAACC,OAAO,CAACD,MAAM;QAC3BE,QAAQN,iBAAiBO,eAAe;QACxCZ,MA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IACF,EAAE,OAAOiC,OAAO;QACd1C,YAAY;YAAE2C,YAAY7B,iBAAiBe,IAAI;YAAEa;YAAOnC;QAAI;IAC9D;IAEAN,UAAU;QACRe,SAAS,IAAI;QACbX,MAAM0B;QACNX,QAAQN,iBAAiBM,MAAM;QAC/BU,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 { 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 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","equals","collectionConfig","Model","adapter","collectionSlug","options","lean","new","session","query","slug","fields","flattenedFields","operation","result","updateOne","doc","findOneAndUpdate","documentsToUpdate","find","projection","_id","length","$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,MAAMD,QAAQL,KAAK;QAAEA,IAAI;YAAEO,QAAQP;QAAG;IAAE,IAAKM;IAE7C,MAAM,EAAEE,gBAAgB,EAAEC,KAAK,EAAE,GAAGf,cAAc;QAChDgB,SAAS,IAAI;QACbC,gBAAgB;IAClB;IAEA,MAAMC,UAAsC;QAC1CC,MAAM;QACNC,KAAK;QACLC,SAAS,MAAMpB,WAAW,IAAI,EAAEQ;IAClC;IAEA,IAAIa,QAAQ,MAAMvB,WAAW;QAC3BiB,SAAS,IAAI;QACbC,gBAAgBH,iBAAiBS,IAAI;QACrCC,QAAQV,iBAAiBW,eAAe;QACxCd;IACF;IAEAR,UAAU;QAAEa,SAAS,IAAI;QAAET;QAAMiB,QAAQV,iBAAiBU,MAAM;QAAEE,WAAW;IAAQ;IAErF,IAAIC,SAAoB,EAAE;IAE1B,IAAI;QACF,IAAIrB,IAAI;YACN,IAAII,cAAc,OAAO;gBACvB,MAAMK,MAAMa,SAAS,CAACN,OAAOf,MAAMW;gBACnC,OAAO;YACT,OAAO;gBACL,MAAMW,MAAM,MAAMd,MAAMe,gBAAgB,CAACR,OAAOf,MAAMW;gBACtDS,SAASE,MAAM;oBAACA;iBAAI,GAAG,EAAE;YAC3B;QACF,OAAO;YACL,IAAI,OAAOrB,UAAU,YAAYA,QAAQ,GAAG;gBAC1C,MAAMuB,oBAAoB,MAAMhB,MAAMiB,IAAI,CACxCV,OACA,CAAC,GACD;oBAAE,GAAGJ,OAAO;oBAAEV;oBAAOyB,YAAY;wBAAEC,KAAK;oBAAE;gBAAE;gBAE9C,IAAIH,kBAAkBI,MAAM,KAAK,GAAG;oBAClC,OAAO;gBACT;gBAEAb,QAAQ;oBAAEY,KAAK;wBAAEE,KAAKL,kBAAkBM,GAAG,CAAC,CAACR,MAAQA,IAAIK,GAAG;oBAAE;gBAAE;YAClE;YAEA,MAAMnB,MAAMV,UAAU,CAACiB,OAAOf,MAAMW;YAEpC,IAAIR,cAAc,OAAO;gBACvB,OAAO;YACT;YAEAiB,SAAS,MAAMZ,MAAMiB,IAAI,CAACV,OAAO,CAAC,GAAGJ;QACvC;IACF,EAAE,OAAOoB,OAAO;QACdpC,YAAY;YAAEqC,YAAYzB,iBAAiBS,IAAI;YAAEe;YAAO7B;QAAI;IAC9D;IAEAN,UAAU;QACRa,SAAS,IAAI;QACbT,MAAMoB;QACNH,QAAQV,iBAAiBU,MAAM;QAC/BE,WAAW;IACb;IAEA,OAAOC;AACT,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/db-mongodb",
3
- "version": "3.32.0-internal.ef3356b",
3
+ "version": "3.32.0-internal.f2e77bd",
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.ef3356b"
52
+ "payload": "3.32.0-internal.f2e77bd"
53
53
  },
54
54
  "peerDependencies": {
55
- "payload": "3.32.0-internal.ef3356b"
55
+ "payload": "3.32.0-internal.f2e77bd"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "pnpm build:types && pnpm build:swc",