@payloadcms/drizzle 3.32.0-canary.3 → 3.32.0-internal.30bda70
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 +3 -0
- 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":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAS,MAAM,SAAS,CAAA;AAUhD,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"updateJobs.d.ts","sourceRoot":"","sources":["../src/updateJobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAS,MAAM,SAAS,CAAA;AAUhD,eAAO,MAAM,UAAU,EAAE,UA2DxB,CAAA"}
|
package/dist/updateJobs.js
CHANGED
|
@@ -3,6 +3,9 @@ import { findMany } from './find/findMany.js';
|
|
|
3
3
|
import { upsertRow } from './upsertRow/index.js';
|
|
4
4
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
5
5
|
export const updateJobs = async function updateMany({ id, data, limit: limitArg, req, returning, sort: sortArg, where: whereArg }) {
|
|
6
|
+
if (!data?.log?.length) {
|
|
7
|
+
delete data.log;
|
|
8
|
+
}
|
|
6
9
|
const whereToUse = id ? {
|
|
7
10
|
id: {
|
|
8
11
|
equals: id
|
package/dist/updateJobs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { UpdateJobs, Where } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: DrizzleAdapter,\n { id, data, limit: limitArg, req, returning, sort: sortArg, where: whereArg },\n) {\n const whereToUse: Where = id ? { id: { equals: id } } : whereArg\n const limit = id ? 1 : limitArg\n\n const db = await getTransaction(this, req)\n const collection = this.payload.collections['payload-jobs'].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const sort = sortArg !== undefined && sortArg !== null ? sortArg : collection.defaultSort\n\n const jobs = await findMany({\n adapter: this,\n collectionSlug: 'payload-jobs',\n fields: collection.flattenedFields,\n limit: id ? 1 : limit,\n pagination: false,\n req,\n sort,\n tableName,\n where: whereToUse,\n })\n if (!jobs.docs.length) {\n return []\n }\n\n const results = []\n\n // TODO: We need to batch this to reduce the amount of db calls. This can get very slow if we are updating a lot of rows.\n for (const job of jobs.docs) {\n const updateData = {\n ...job,\n ...data,\n }\n\n const result = await upsertRow({\n id: job.id,\n adapter: this,\n data: updateData,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n operation: 'update',\n req,\n tableName,\n })\n results.push(result)\n }\n\n if (returning === false) {\n return null\n }\n\n return results\n}\n"],"names":["toSnakeCase","findMany","upsertRow","getTransaction","updateJobs","updateMany","id","data","limit","limitArg","req","returning","sort","sortArg","where","whereArg","whereToUse","equals","db","collection","payload","collections","config","tableName","tableNameMap","get","slug","undefined","defaultSort","jobs","adapter","collectionSlug","fields","flattenedFields","pagination","docs","
|
|
1
|
+
{"version":3,"sources":["../src/updateJobs.ts"],"sourcesContent":["import type { UpdateJobs, Where } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const updateJobs: UpdateJobs = async function updateMany(\n this: DrizzleAdapter,\n { id, data, limit: limitArg, req, returning, sort: sortArg, where: whereArg },\n) {\n if (!(data?.log as object[])?.length) {\n delete data.log\n }\n const whereToUse: Where = id ? { id: { equals: id } } : whereArg\n const limit = id ? 1 : limitArg\n\n const db = await getTransaction(this, req)\n const collection = this.payload.collections['payload-jobs'].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const sort = sortArg !== undefined && sortArg !== null ? sortArg : collection.defaultSort\n\n const jobs = await findMany({\n adapter: this,\n collectionSlug: 'payload-jobs',\n fields: collection.flattenedFields,\n limit: id ? 1 : limit,\n pagination: false,\n req,\n sort,\n tableName,\n where: whereToUse,\n })\n if (!jobs.docs.length) {\n return []\n }\n\n const results = []\n\n // TODO: We need to batch this to reduce the amount of db calls. This can get very slow if we are updating a lot of rows.\n for (const job of jobs.docs) {\n const updateData = {\n ...job,\n ...data,\n }\n\n const result = await upsertRow({\n id: job.id,\n adapter: this,\n data: updateData,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n operation: 'update',\n req,\n tableName,\n })\n\n results.push(result)\n }\n\n if (returning === false) {\n return null\n }\n\n return results\n}\n"],"names":["toSnakeCase","findMany","upsertRow","getTransaction","updateJobs","updateMany","id","data","limit","limitArg","req","returning","sort","sortArg","where","whereArg","log","length","whereToUse","equals","db","collection","payload","collections","config","tableName","tableNameMap","get","slug","undefined","defaultSort","jobs","adapter","collectionSlug","fields","flattenedFields","pagination","docs","results","job","updateData","result","ignoreResult","operation","push"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,aAAyB,eAAeC,WAEnD,EAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAOC,QAAQ,EAAEC,GAAG,EAAEC,SAAS,EAAEC,MAAMC,OAAO,EAAEC,OAAOC,QAAQ,EAAE;IAE7E,IAAI,CAAER,MAAMS,KAAkBC,QAAQ;QACpC,OAAOV,KAAKS,GAAG;IACjB;IACA,MAAME,aAAoBZ,KAAK;QAAEA,IAAI;YAAEa,QAAQb;QAAG;IAAE,IAAIS;IACxD,MAAMP,QAAQF,KAAK,IAAIG;IAEvB,MAAMW,KAAK,MAAMjB,eAAe,IAAI,EAAEO;IACtC,MAAMW,aAAa,IAAI,CAACC,OAAO,CAACC,WAAW,CAAC,eAAe,CAACC,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC3B,YAAYqB,WAAWO,IAAI;IACnE,MAAMhB,OAAOC,YAAYgB,aAAahB,YAAY,OAAOA,UAAUQ,WAAWS,WAAW;IAEzF,MAAMC,OAAO,MAAM9B,SAAS;QAC1B+B,SAAS,IAAI;QACbC,gBAAgB;QAChBC,QAAQb,WAAWc,eAAe;QAClC3B,OAAOF,KAAK,IAAIE;QAChB4B,YAAY;QACZ1B;QACAE;QACAa;QACAX,OAAOI;IACT;IACA,IAAI,CAACa,KAAKM,IAAI,CAACpB,MAAM,EAAE;QACrB,OAAO,EAAE;IACX;IAEA,MAAMqB,UAAU,EAAE;IAElB,yHAAyH;IACzH,KAAK,MAAMC,OAAOR,KAAKM,IAAI,CAAE;QAC3B,MAAMG,aAAa;YACjB,GAAGD,GAAG;YACN,GAAGhC,IAAI;QACT;QAEA,MAAMkC,SAAS,MAAMvC,UAAU;YAC7BI,IAAIiC,IAAIjC,EAAE;YACV0B,SAAS,IAAI;YACbzB,MAAMiC;YACNpB;YACAc,QAAQb,WAAWc,eAAe;YAClCO,cAAc/B,cAAc;YAC5BgC,WAAW;YACXjC;YACAe;QACF;QAEAa,QAAQM,IAAI,CAACH;IACf;IAEA,IAAI9B,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAO2B;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "3.32.0-
|
|
3
|
+
"version": "3.32.0-internal.30bda70",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"@types/pg": "8.10.2",
|
|
54
54
|
"@types/to-snake-case": "1.0.0",
|
|
55
55
|
"@payloadcms/eslint-config": "3.28.0",
|
|
56
|
-
"payload": "3.32.0-
|
|
56
|
+
"payload": "3.32.0-internal.30bda70"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"payload": "3.32.0-
|
|
59
|
+
"payload": "3.32.0-internal.30bda70"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "pnpm build:swc && pnpm build:types",
|