@payloadcms/db-mongodb 3.32.0-canary.2 → 3.32.0-internal.ef3356b
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/updateJobs.d.ts.map +1 -1
- package/dist/updateJobs.js +15 -3
- package/dist/updateJobs.js.map +1 -1
- package/package.json +3 -3
package/dist/updateJobs.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|
package/dist/updateJobs.js
CHANGED
|
@@ -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
|
const where = id ? {
|
|
8
9
|
id: {
|
|
9
10
|
equals: id
|
|
@@ -13,6 +14,13 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
13
14
|
adapter: this,
|
|
14
15
|
collectionSlug: 'payload-jobs'
|
|
15
16
|
});
|
|
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
|
+
});
|
|
16
24
|
const options = {
|
|
17
25
|
lean: true,
|
|
18
26
|
new: true,
|
|
@@ -49,7 +57,8 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
49
57
|
limit,
|
|
50
58
|
projection: {
|
|
51
59
|
_id: 1
|
|
52
|
-
}
|
|
60
|
+
},
|
|
61
|
+
sort
|
|
53
62
|
});
|
|
54
63
|
if (documentsToUpdate.length === 0) {
|
|
55
64
|
return null;
|
|
@@ -64,7 +73,10 @@ export const updateJobs = async function updateMany({ id, data, limit, req, retu
|
|
|
64
73
|
if (returning === false) {
|
|
65
74
|
return null;
|
|
66
75
|
}
|
|
67
|
-
result = await Model.find(query, {},
|
|
76
|
+
result = await Model.find(query, {}, {
|
|
77
|
+
...options,
|
|
78
|
+
sort
|
|
79
|
+
});
|
|
68
80
|
}
|
|
69
81
|
} catch (error) {
|
|
70
82
|
handleError({
|
package/dist/updateJobs.js.map
CHANGED
|
@@ -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 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
|
|
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;QAA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AAG,CAAC,CAACR,MAAQA,IAAIK,GAAG;oBAAE;gBAAE;YAClE;YAEA,MAAMvB,MAAMZ,UAAU,CAACyB,OAAOvB,MAAMmB;YAEpC,IAAIhB,cAAc,OAAO;gBACvB,OAAO;YACT;YAEAuB,SAAS,MAAMhB,MAAMqB,IAAI,CACvBR,OACA,CAAC,GACD;gBACE,GAAGJ,OAAO;gBACVf;YACF;QAEJ;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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "3.32.0-
|
|
3
|
+
"version": "3.32.0-internal.ef3356b",
|
|
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-
|
|
52
|
+
"payload": "3.32.0-internal.ef3356b"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"payload": "3.32.0-
|
|
55
|
+
"payload": "3.32.0-internal.ef3356b"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "pnpm build:types && pnpm build:swc",
|