@payloadcms/drizzle 3.25.0 → 3.26.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/create.d.ts.map +1 -1
- package/dist/create.js +6 -2
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts +1 -1
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +6 -2
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +6 -2
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createVersion.d.ts +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +4 -1
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +2 -2
- package/dist/deleteOne.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/updateGlobal.d.ts +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +6 -2
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +6 -2
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateMany.d.ts +3 -0
- package/dist/updateMany.d.ts.map +1 -0
- package/dist/updateMany.js +66 -0
- package/dist/updateMany.js.map +1 -0
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +6 -2
- package/dist/updateOne.js.map +1 -1
- package/dist/updateVersion.d.ts +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +6 -2
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +5 -0
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/types.d.ts +1 -1
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/package.json +3 -3
package/dist/create.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AASrC,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AASrC,eAAO,MAAM,MAAM,EAAE,MA0BpB,CAAA"}
|
package/dist/create.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import toSnakeCase from 'to-snake-case';
|
|
2
2
|
import { upsertRow } from './upsertRow/index.js';
|
|
3
3
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
|
-
export const create = async function create({ collection: collectionSlug, data, req, select }) {
|
|
4
|
+
export const create = async function create({ collection: collectionSlug, data, req, select, returning }) {
|
|
5
5
|
const db = await getTransaction(this, req);
|
|
6
6
|
const collection = this.payload.collections[collectionSlug].config;
|
|
7
7
|
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
|
@@ -13,8 +13,12 @@ export const create = async function create({ collection: collectionSlug, data,
|
|
|
13
13
|
operation: 'create',
|
|
14
14
|
req,
|
|
15
15
|
select,
|
|
16
|
-
tableName
|
|
16
|
+
tableName,
|
|
17
|
+
ignoreResult: returning === false
|
|
17
18
|
});
|
|
19
|
+
if (returning === false) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
18
22
|
return result;
|
|
19
23
|
};
|
|
20
24
|
|
package/dist/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const create: Create = async function create(\n this: DrizzleAdapter,\n { collection: collectionSlug, data, req, select },\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.flattenedFields,\n operation: 'create',\n req,\n select,\n tableName,\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","getTransaction","create","collection","collectionSlug","data","req","select","db","payload","collections","config","tableName","tableNameMap","get","slug","result","adapter","fields","flattenedFields","operation"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const create: Create = async function create(\n this: DrizzleAdapter,\n { collection: collectionSlug, data, req, select, returning },\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.flattenedFields,\n operation: 'create',\n req,\n select,\n tableName,\n ignoreResult: returning === false,\n })\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","getTransaction","create","collection","collectionSlug","data","req","select","returning","db","payload","collections","config","tableName","tableNameMap","get","slug","result","adapter","fields","flattenedFields","operation","ignoreResult"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAE;IAE5D,MAAMC,KAAK,MAAMR,eAAe,IAAI,EAAEK;IACtC,MAAMH,aAAa,IAAI,CAACO,OAAO,CAACC,WAAW,CAACP,eAAe,CAACQ,MAAM;IAElE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYI,WAAWa,IAAI;IAEnE,MAAMC,SAAS,MAAMjB,UAAU;QAC7BkB,SAAS,IAAI;QACbb;QACAI;QACAU,QAAQhB,WAAWiB,eAAe;QAClCC,WAAW;QACXf;QACAC;QACAM;QACAS,cAAcd,cAAc;IAC9B;IAEA,IAAIA,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAOS;AACT,EAAC"}
|
package/dist/createGlobal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CreateGlobalArgs } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function createGlobal<T extends Record<string, unknown>>(this: DrizzleAdapter, { slug, data, req }: CreateGlobalArgs): Promise<T>;
|
|
3
|
+
export declare function createGlobal<T extends Record<string, unknown>>(this: DrizzleAdapter, { slug, data, req, returning }: CreateGlobalArgs): Promise<T>;
|
|
4
4
|
//# sourceMappingURL=createGlobal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,cAAc,EACpB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,cAAc,EACpB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,gBAAgB,GAC/C,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
|
package/dist/createGlobal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import toSnakeCase from 'to-snake-case';
|
|
2
2
|
import { upsertRow } from './upsertRow/index.js';
|
|
3
3
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
|
-
export async function createGlobal({ slug, data, req }) {
|
|
4
|
+
export async function createGlobal({ slug, data, req, returning }) {
|
|
5
5
|
const db = await getTransaction(this, req);
|
|
6
6
|
const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
|
|
7
7
|
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
|
|
@@ -13,8 +13,12 @@ export async function createGlobal({ slug, data, req }) {
|
|
|
13
13
|
fields: globalConfig.flattenedFields,
|
|
14
14
|
operation: 'create',
|
|
15
15
|
req,
|
|
16
|
-
tableName
|
|
16
|
+
tableName,
|
|
17
|
+
ignoreResult: returning === false
|
|
17
18
|
});
|
|
19
|
+
if (returning === false) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
18
22
|
result.globalType = slug;
|
|
19
23
|
return result;
|
|
20
24
|
}
|
package/dist/createGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function createGlobal<T extends Record<string, unknown>>(\n this: DrizzleAdapter,\n { slug, data, req }: CreateGlobalArgs,\n): Promise<T> {\n const db = await getTransaction(this, req)\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n data.createdAt = new Date().toISOString()\n\n const result = await upsertRow<{ globalType: string } & T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.flattenedFields,\n operation: 'create',\n req,\n tableName,\n })\n\n result.globalType = slug\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","getTransaction","createGlobal","slug","data","req","db","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","createdAt","Date","toISOString","result","adapter","fields","flattenedFields","operation","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAoB;
|
|
1
|
+
{"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function createGlobal<T extends Record<string, unknown>>(\n this: DrizzleAdapter,\n { slug, data, req, returning }: CreateGlobalArgs,\n): Promise<T> {\n const db = await getTransaction(this, req)\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n data.createdAt = new Date().toISOString()\n\n const result = await upsertRow<{ globalType: string } & T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.flattenedFields,\n operation: 'create',\n req,\n tableName,\n ignoreResult: returning === false,\n })\n\n if (returning === false) {\n return null\n }\n\n result.globalType = slug\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","getTransaction","createGlobal","slug","data","req","returning","db","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","createdAt","Date","toISOString","result","adapter","fields","flattenedFields","operation","ignoreResult","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,SAAS,EAAoB;IAEhD,MAAMC,KAAK,MAAMN,eAAe,IAAI,EAAEI;IACtC,MAAMG,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOR,IAAI,KAAKA;IAElF,MAAMU,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYS,aAAaL,IAAI;IAErEC,KAAKY,SAAS,GAAG,IAAIC,OAAOC,WAAW;IAEvC,MAAMC,SAAS,MAAMnB,UAAsC;QACzDoB,SAAS,IAAI;QACbhB;QACAG;QACAc,QAAQb,aAAac,eAAe;QACpCC,WAAW;QACXlB;QACAQ;QACAW,cAAclB,cAAc;IAC9B;IAEA,IAAIA,cAAc,OAAO;QACvB,OAAO;IACT;IAEAa,OAAOM,UAAU,GAAGtB;IAEpB,OAAOgB;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CreateGlobalVersionArgs, TypeWithID, TypeWithVersion } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function createGlobalVersion<T extends TypeWithID>(this: DrizzleAdapter, { autosave, createdAt, globalSlug, publishedLocale, req, select, snapshot, updatedAt, versionData, }: CreateGlobalVersionArgs): Promise<TypeWithVersion<T>>;
|
|
3
|
+
export declare function createGlobalVersion<T extends TypeWithID>(this: DrizzleAdapter, { autosave, createdAt, globalSlug, publishedLocale, req, select, snapshot, updatedAt, versionData, returning, }: CreateGlobalVersionArgs): Promise<TypeWithVersion<T>>;
|
|
4
4
|
//# sourceMappingURL=createGlobalVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAMnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,cAAc,EACpB,EACE,QAAQ,EACR,SAAS,EACT,UAAU,EACV,eAAe,EACf,GAAG,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,
|
|
1
|
+
{"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAMnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,cAAc,EACpB,EACE,QAAQ,EACR,SAAS,EACT,UAAU,EACV,eAAe,EACf,GAAG,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,GACV,EAAE,uBAAuB,+BA4C3B"}
|
|
@@ -3,7 +3,7 @@ import { buildVersionGlobalFields } from 'payload';
|
|
|
3
3
|
import toSnakeCase from 'to-snake-case';
|
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
|
5
5
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
6
|
-
export async function createGlobalVersion({ autosave, createdAt, globalSlug, publishedLocale, req, select, snapshot, updatedAt, versionData }) {
|
|
6
|
+
export async function createGlobalVersion({ autosave, createdAt, globalSlug, publishedLocale, req, select, snapshot, updatedAt, versionData, returning }) {
|
|
7
7
|
const db = await getTransaction(this, req);
|
|
8
8
|
const global = this.payload.globals.config.find(({ slug })=>slug === globalSlug);
|
|
9
9
|
const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`);
|
|
@@ -23,7 +23,8 @@ export async function createGlobalVersion({ autosave, createdAt, globalSlug, pub
|
|
|
23
23
|
operation: 'create',
|
|
24
24
|
req,
|
|
25
25
|
select,
|
|
26
|
-
tableName
|
|
26
|
+
tableName,
|
|
27
|
+
ignoreResult: returning === false ? 'idOnly' : false
|
|
27
28
|
});
|
|
28
29
|
const table = this.tables[tableName];
|
|
29
30
|
if (global.versions.drafts) {
|
|
@@ -36,6 +37,9 @@ export async function createGlobalVersion({ autosave, createdAt, globalSlug, pub
|
|
|
36
37
|
`
|
|
37
38
|
});
|
|
38
39
|
}
|
|
40
|
+
if (returning === false) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
39
43
|
return result;
|
|
40
44
|
}
|
|
41
45
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { CreateGlobalVersionArgs, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {\n autosave,\n createdAt,\n globalSlug,\n publishedLocale,\n req,\n select,\n snapshot,\n updatedAt,\n versionData,\n }: CreateGlobalVersionArgs,\n) {\n const db = await getTransaction(this, req)\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`)\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n createdAt,\n latest: true,\n publishedLocale,\n snapshot,\n updatedAt,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(this.payload.config, global, true),\n operation: 'create',\n req,\n select,\n tableName,\n })\n\n const table = this.tables[tableName]\n if (global.versions.drafts) {\n await this.execute({\n db,\n sql: sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `,\n })\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","getTransaction","createGlobalVersion","autosave","createdAt","globalSlug","publishedLocale","req","select","snapshot","updatedAt","versionData","db","global","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","result","adapter","data","latest","version","fields","operation","table","tables","versions","drafts","execute","id"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,wBAAwB,QAAQ,UAAS;AAClD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,oBAEpB,EACEC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,eAAe,EACfC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,WAAW,
|
|
1
|
+
{"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { CreateGlobalVersionArgs, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {\n autosave,\n createdAt,\n globalSlug,\n publishedLocale,\n req,\n select,\n snapshot,\n updatedAt,\n versionData,\n returning,\n }: CreateGlobalVersionArgs,\n) {\n const db = await getTransaction(this, req)\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n\n const tableName = this.tableNameMap.get(`_${toSnakeCase(global.slug)}${this.versionsSuffix}`)\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n createdAt,\n latest: true,\n publishedLocale,\n snapshot,\n updatedAt,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(this.payload.config, global, true),\n operation: 'create',\n req,\n select,\n tableName,\n ignoreResult: returning === false ? 'idOnly' : false,\n })\n\n const table = this.tables[tableName]\n if (global.versions.drafts) {\n await this.execute({\n db,\n sql: sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `,\n })\n }\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","getTransaction","createGlobalVersion","autosave","createdAt","globalSlug","publishedLocale","req","select","snapshot","updatedAt","versionData","returning","db","global","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","result","adapter","data","latest","version","fields","operation","ignoreResult","table","tables","versions","drafts","execute","id"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,wBAAwB,QAAQ,UAAS;AAClD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,oBAEpB,EACEC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,eAAe,EACfC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,WAAW,EACXC,SAAS,EACe;IAE1B,MAAMC,KAAK,MAAMZ,eAAe,IAAI,EAAEM;IACtC,MAAMO,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASd;IAEvE,MAAMe,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEvB,YAAYe,OAAOK,IAAI,IAAI,IAAI,CAACI,cAAc,EAAE;IAE5F,MAAMC,SAAS,MAAMxB,UAA8B;QACjDyB,SAAS,IAAI;QACbC,MAAM;YACJvB;YACAC;YACAuB,QAAQ;YACRrB;YACAG;YACAC;YACAkB,SAASjB;QACX;QACAE;QACAgB,QAAQ/B,yBAAyB,IAAI,CAACiB,OAAO,CAACE,MAAM,EAAEH,QAAQ;QAC9DgB,WAAW;QACXvB;QACAC;QACAY;QACAW,cAAcnB,cAAc,QAAQ,WAAW;IACjD;IAEA,MAAMoB,QAAQ,IAAI,CAACC,MAAM,CAACb,UAAU;IACpC,IAAIN,OAAOoB,QAAQ,CAACC,MAAM,EAAE;QAC1B,MAAM,IAAI,CAACC,OAAO,CAAC;YACjBvB;YACAhB,KAAKA,GAAG,CAAC;iBACE,EAAEmC,MAAM;;gBAET,EAAEA,MAAMK,EAAE,CAAC,IAAI,EAAEb,OAAOa,EAAE,CAAC;QACnC,CAAC;QACL;IACF;IAEA,IAAIzB,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAOY;AACT"}
|
package/dist/createVersion.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CreateVersionArgs, TypeWithID, TypeWithVersion } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function createVersion<T extends TypeWithID>(this: DrizzleAdapter, { autosave, collectionSlug, createdAt, parent, publishedLocale, req, select, snapshot, updatedAt, versionData, }: CreateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
|
3
|
+
export declare function createVersion<T extends TypeWithID>(this: DrizzleAdapter, { autosave, collectionSlug, createdAt, parent, publishedLocale, req, select, snapshot, updatedAt, versionData, returning, }: CreateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
|
4
4
|
//# sourceMappingURL=createVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,cAAc,EACpB,EACE,QAAQ,EACR,cAAc,EACd,SAAS,EACT,MAAM,EACN,eAAe,EACf,GAAG,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,
|
|
1
|
+
{"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAM7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,cAAc,EACpB,EACE,QAAQ,EACR,cAAc,EACd,SAAS,EACT,MAAM,EACN,eAAe,EACf,GAAG,EACH,MAAM,EACN,QAAQ,EACR,SAAS,EACT,WAAW,EACX,SAAS,GACV,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAuDxB"}
|
package/dist/createVersion.js
CHANGED
|
@@ -3,7 +3,7 @@ import { buildVersionCollectionFields } from 'payload';
|
|
|
3
3
|
import toSnakeCase from 'to-snake-case';
|
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
|
5
5
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
6
|
-
export async function createVersion({ autosave, collectionSlug, createdAt, parent, publishedLocale, req, select, snapshot, updatedAt, versionData }) {
|
|
6
|
+
export async function createVersion({ autosave, collectionSlug, createdAt, parent, publishedLocale, req, select, snapshot, updatedAt, versionData, returning }) {
|
|
7
7
|
const db = await getTransaction(this, req);
|
|
8
8
|
const collection = this.payload.collections[collectionSlug].config;
|
|
9
9
|
const defaultTableName = toSnakeCase(collection.slug);
|
|
@@ -47,6 +47,9 @@ export async function createVersion({ autosave, collectionSlug, createdAt, paren
|
|
|
47
47
|
`
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
+
if (returning === false) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
50
53
|
return result;
|
|
51
54
|
}
|
|
52
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {\n autosave,\n collectionSlug,\n createdAt,\n parent,\n publishedLocale,\n req,\n select,\n snapshot,\n updatedAt,\n versionData,\n }: CreateVersionArgs<T>,\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n const defaultTableName = toSnakeCase(collection.slug)\n\n const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`)\n\n const version = { ...versionData }\n if (version.id) {\n delete version.id\n }\n\n const data: Record<string, unknown> = {\n autosave,\n createdAt,\n latest: true,\n parent,\n publishedLocale,\n snapshot,\n updatedAt,\n version,\n }\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data,\n db,\n fields: buildVersionCollectionFields(this.payload.config, collection, true),\n operation: 'create',\n req,\n select,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (collection.versions.drafts) {\n await this.execute({\n db,\n sql: sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id}\n AND ${table.parent} = ${parent}\n AND ${table.updatedAt} < ${result.updatedAt}\n `,\n })\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","toSnakeCase","upsertRow","getTransaction","createVersion","autosave","collectionSlug","createdAt","parent","publishedLocale","req","select","snapshot","updatedAt","versionData","db","collection","payload","collections","config","defaultTableName","slug","tableName","tableNameMap","get","versionsSuffix","version","id","data","latest","result","adapter","fields","operation","table","tables","versions","drafts","execute"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,cAEpB,EACEC,QAAQ,EACRC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,eAAe,EACfC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,WAAW,
|
|
1
|
+
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, TypeWithID, TypeWithVersion } from 'payload'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {\n autosave,\n collectionSlug,\n createdAt,\n parent,\n publishedLocale,\n req,\n select,\n snapshot,\n updatedAt,\n versionData,\n returning,\n }: CreateVersionArgs<T>,\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n const defaultTableName = toSnakeCase(collection.slug)\n\n const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`)\n\n const version = { ...versionData }\n if (version.id) {\n delete version.id\n }\n\n const data: Record<string, unknown> = {\n autosave,\n createdAt,\n latest: true,\n parent,\n publishedLocale,\n snapshot,\n updatedAt,\n version,\n }\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data,\n db,\n fields: buildVersionCollectionFields(this.payload.config, collection, true),\n operation: 'create',\n req,\n select,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (collection.versions.drafts) {\n await this.execute({\n db,\n sql: sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id}\n AND ${table.parent} = ${parent}\n AND ${table.updatedAt} < ${result.updatedAt}\n `,\n })\n }\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","toSnakeCase","upsertRow","getTransaction","createVersion","autosave","collectionSlug","createdAt","parent","publishedLocale","req","select","snapshot","updatedAt","versionData","returning","db","collection","payload","collections","config","defaultTableName","slug","tableName","tableNameMap","get","versionsSuffix","version","id","data","latest","result","adapter","fields","operation","table","tables","versions","drafts","execute"],"mappings":"AAEA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,cAEpB,EACEC,QAAQ,EACRC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,eAAe,EACfC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,SAAS,EACTC,WAAW,EACXC,SAAS,EACY;IAEvB,MAAMC,KAAK,MAAMb,eAAe,IAAI,EAAEO;IACtC,MAAMO,aAAa,IAAI,CAACC,OAAO,CAACC,WAAW,CAACb,eAAe,CAACc,MAAM;IAClE,MAAMC,mBAAmBpB,YAAYgB,WAAWK,IAAI;IAEpD,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEJ,mBAAmB,IAAI,CAACK,cAAc,EAAE;IAEpF,MAAMC,UAAU;QAAE,GAAGb,WAAW;IAAC;IACjC,IAAIa,QAAQC,EAAE,EAAE;QACd,OAAOD,QAAQC,EAAE;IACnB;IAEA,MAAMC,OAAgC;QACpCxB;QACAE;QACAuB,QAAQ;QACRtB;QACAC;QACAG;QACAC;QACAc;IACF;IAEA,MAAMI,SAAS,MAAM7B,UAA8B;QACjD8B,SAAS,IAAI;QACbH;QACAb;QACAiB,QAAQjC,6BAA6B,IAAI,CAACkB,OAAO,CAACE,MAAM,EAAEH,YAAY;QACtEiB,WAAW;QACXxB;QACAC;QACAY;IACF;IAEA,MAAMY,QAAQ,IAAI,CAACC,MAAM,CAACb,UAAU;IAEpC,IAAIN,WAAWoB,QAAQ,CAACC,MAAM,EAAE;QAC9B,MAAM,IAAI,CAACC,OAAO,CAAC;YACjBvB;YACAjB,KAAKA,GAAG,CAAC;eACA,EAAEoC,MAAM;;cAET,EAAEA,MAAMP,EAAE,CAAC,IAAI,EAAEG,OAAOH,EAAE,CAAC;cAC3B,EAAEO,MAAM3B,MAAM,CAAC,GAAG,EAAEA,OAAO;cAC3B,EAAE2B,MAAMtB,SAAS,CAAC,GAAG,EAAEkB,OAAOlB,SAAS,CAAC;MAChD,CAAC;QACH;IACF;IAEA,IAAIE,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAOgB;AACT"}
|
package/dist/deleteOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAaxC,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAaxC,eAAO,MAAM,SAAS,EAAE,SAkEvB,CAAA"}
|
package/dist/deleteOne.js
CHANGED
|
@@ -5,7 +5,7 @@ import buildQuery from './queries/buildQuery.js';
|
|
|
5
5
|
import { selectDistinct } from './queries/selectDistinct.js';
|
|
6
6
|
import { transform } from './transform/read/index.js';
|
|
7
7
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
8
|
-
export const deleteOne = async function deleteOne({ collection: collectionSlug, req, select, where: whereArg }) {
|
|
8
|
+
export const deleteOne = async function deleteOne({ collection: collectionSlug, req, select, where: whereArg, returning }) {
|
|
9
9
|
const db = await getTransaction(this, req);
|
|
10
10
|
const collection = this.payload.collections[collectionSlug].config;
|
|
11
11
|
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
|
@@ -49,7 +49,7 @@ export const deleteOne = async function deleteOne({ collection: collectionSlug,
|
|
|
49
49
|
findManyArgs.where = where;
|
|
50
50
|
docToDelete = await db.query[tableName].findFirst(findManyArgs);
|
|
51
51
|
}
|
|
52
|
-
const result = transform({
|
|
52
|
+
const result = returning === false ? null : transform({
|
|
53
53
|
adapter: this,
|
|
54
54
|
config: this.payload.config,
|
|
55
55
|
data: docToDelete,
|
package/dist/deleteOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne } from 'payload'\n\nimport { eq } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { buildFindManyArgs } from './find/buildFindManyArgs.js'\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { transform } from './transform/read/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: DrizzleAdapter,\n { collection: collectionSlug, req, select, where: whereArg },\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n let docToDelete: Record<string, unknown>\n\n const { joins, selectFields, where } = buildQuery({\n adapter: this,\n fields: collection.flattenedFields,\n locale: req?.locale,\n tableName,\n where: whereArg,\n })\n\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n chainedMethods: [{ args: [1], method: 'limit' }],\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n docToDelete = await db.query[tableName].findFirst({\n where: eq(this.tables[tableName].id, selectDistinctResult[0].id),\n })\n } else {\n const findManyArgs = buildFindManyArgs({\n adapter: this,\n depth: 0,\n fields: collection.flattenedFields,\n joinQuery: false,\n select,\n tableName,\n })\n\n findManyArgs.where = where\n\n docToDelete = await db.query[tableName].findFirst(findManyArgs)\n }\n\n const result
|
|
1
|
+
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne } from 'payload'\n\nimport { eq } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { buildFindManyArgs } from './find/buildFindManyArgs.js'\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { transform } from './transform/read/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: DrizzleAdapter,\n { collection: collectionSlug, req, select, where: whereArg, returning },\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n let docToDelete: Record<string, unknown>\n\n const { joins, selectFields, where } = buildQuery({\n adapter: this,\n fields: collection.flattenedFields,\n locale: req?.locale,\n tableName,\n where: whereArg,\n })\n\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n chainedMethods: [{ args: [1], method: 'limit' }],\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n docToDelete = await db.query[tableName].findFirst({\n where: eq(this.tables[tableName].id, selectDistinctResult[0].id),\n })\n } else {\n const findManyArgs = buildFindManyArgs({\n adapter: this,\n depth: 0,\n fields: collection.flattenedFields,\n joinQuery: false,\n select,\n tableName,\n })\n\n findManyArgs.where = where\n\n docToDelete = await db.query[tableName].findFirst(findManyArgs)\n }\n\n const result =\n returning === false\n ? null\n : transform({\n adapter: this,\n config: this.payload.config,\n data: docToDelete,\n fields: collection.flattenedFields,\n joinQuery: false,\n })\n\n await this.deleteWhere({\n db,\n tableName,\n where: eq(this.tables[tableName].id, docToDelete.id),\n })\n\n return result\n}\n"],"names":["eq","toSnakeCase","buildFindManyArgs","buildQuery","selectDistinct","transform","getTransaction","deleteOne","collection","collectionSlug","req","select","where","whereArg","returning","db","payload","collections","config","tableName","tableNameMap","get","slug","docToDelete","joins","selectFields","adapter","fields","flattenedFields","locale","selectDistinctResult","chainedMethods","args","method","id","query","findFirst","tables","findManyArgs","depth","joinQuery","result","data","deleteWhere"],"mappings":"AAEA,SAASA,EAAE,QAAQ,cAAa;AAChC,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,YAAYC,cAAc,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAOC,QAAQ,EAAEC,SAAS,EAAE;IAEvE,MAAMC,KAAK,MAAMT,eAAe,IAA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,CAACqC,MAAM,CAAClB,UAAU,CAACe,EAAE,EAAEX,YAAYW,EAAE;IACrD;IAEA,OAAOO;AACT,EAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export { commitTransaction } from './transactions/commitTransaction.js';
|
|
|
33
33
|
export { rollbackTransaction } from './transactions/rollbackTransaction.js';
|
|
34
34
|
export { updateGlobal } from './updateGlobal.js';
|
|
35
35
|
export { updateGlobalVersion } from './updateGlobalVersion.js';
|
|
36
|
+
export { updateMany } from './updateMany.js';
|
|
36
37
|
export { updateOne } from './updateOne.js';
|
|
37
38
|
export { updateVersion } from './updateVersion.js';
|
|
38
39
|
export { upsertRow } from './upsertRow/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YA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,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAA;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ export { commitTransaction } from './transactions/commitTransaction.js';
|
|
|
32
32
|
export { rollbackTransaction } from './transactions/rollbackTransaction.js';
|
|
33
33
|
export { updateGlobal } from './updateGlobal.js';
|
|
34
34
|
export { updateGlobalVersion } from './updateGlobalVersion.js';
|
|
35
|
+
export { updateMany } from './updateMany.js';
|
|
35
36
|
export { updateOne } from './updateOne.js';
|
|
36
37
|
export { updateVersion } from './updateVersion.js';
|
|
37
38
|
export { upsertRow } from './upsertRow/index.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { chainMethods } from './find/chainMethods.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findMigrationDir } from './findMigrationDir.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateOne } from './updateOne.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport { createSchemaGenerator } from './utilities/createSchemaGenerator.js'\nexport { executeSchemaHooks } from './utilities/executeSchemaHooks.js'\nexport { extendDrizzleTable } from './utilities/extendDrizzleTable.js'\nexport { hasLocalesTable } from './utilities/hasLocalesTable.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","chainMethods","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateOne","updateVersion","upsertRow","buildCreateMigration","buildIndexName","createSchemaGenerator","executeSchemaHooks","extendDrizzleTable","hasLocalesTable","pushDevSchema","validateExistingBlockIsIdentical"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,UAAU,QAAQ,kBAAiB;AAC5C,SAASC,kBAAkB,QAAQ,0BAAyB;AAC5D,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,cAAc,QAAQ,sBAAqB;AACpD,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,WAAW,QAAQ,2BAA0B;AAEtD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,qBAAqB,QAAQ,oCAAmC;AACzE,SAASC,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,gBAAgB,QAAQ,qCAAoC;AACrE,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,YAAY,QAAQ,oBAAmB;AAChD,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,SAAS,QAAQ,iBAAgB;AAC1C,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,qBAAqB,QAAQ,uCAAsC;AAC5E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { count } from './count.js'\nexport { countGlobalVersions } from './countGlobalVersions.js'\nexport { countVersions } from './countVersions.js'\nexport { create } from './create.js'\nexport { createGlobal } from './createGlobal.js'\nexport { createGlobalVersion } from './createGlobalVersion.js'\nexport { createTableName } from './createTableName.js'\nexport { createVersion } from './createVersion.js'\nexport { deleteMany } from './deleteMany.js'\nexport { deleteOne } from './deleteOne.js'\nexport { deleteVersions } from './deleteVersions.js'\nexport { destroy } from './destroy.js'\nexport { find } from './find.js'\nexport { chainMethods } from './find/chainMethods.js'\nexport { findGlobal } from './findGlobal.js'\nexport { findGlobalVersions } from './findGlobalVersions.js'\nexport { findMigrationDir } from './findMigrationDir.js'\nexport { findOne } from './findOne.js'\nexport { findVersions } from './findVersions.js'\nexport { migrate } from './migrate.js'\nexport { migrateDown } from './migrateDown.js'\nexport { migrateFresh } from './migrateFresh.js'\nexport { migrateRefresh } from './migrateRefresh.js'\nexport { migrateReset } from './migrateReset.js'\nexport { migrateStatus } from './migrateStatus.js'\nexport { operatorMap } from './queries/operatorMap.js'\nexport type { Operators } from './queries/operatorMap.js'\nexport { queryDrafts } from './queryDrafts.js'\nexport { buildDrizzleRelations } from './schema/buildDrizzleRelations.js'\nexport { buildRawSchema } from './schema/buildRawSchema.js'\nexport { beginTransaction } from './transactions/beginTransaction.js'\nexport { commitTransaction } from './transactions/commitTransaction.js'\nexport { rollbackTransaction } from './transactions/rollbackTransaction.js'\nexport { updateGlobal } from './updateGlobal.js'\nexport { updateGlobalVersion } from './updateGlobalVersion.js'\nexport { updateMany } from './updateMany.js'\nexport { updateOne } from './updateOne.js'\nexport { updateVersion } from './updateVersion.js'\nexport { upsertRow } from './upsertRow/index.js'\nexport { buildCreateMigration } from './utilities/buildCreateMigration.js'\nexport { buildIndexName } from './utilities/buildIndexName.js'\nexport { createSchemaGenerator } from './utilities/createSchemaGenerator.js'\nexport { executeSchemaHooks } from './utilities/executeSchemaHooks.js'\nexport { extendDrizzleTable } from './utilities/extendDrizzleTable.js'\nexport { hasLocalesTable } from './utilities/hasLocalesTable.js'\nexport { pushDevSchema } from './utilities/pushDevSchema.js'\nexport { validateExistingBlockIsIdentical } from './utilities/validateExistingBlockIsIdentical.js'\n"],"names":["count","countGlobalVersions","countVersions","create","createGlobal","createGlobalVersion","createTableName","createVersion","deleteMany","deleteOne","deleteVersions","destroy","find","chainMethods","findGlobal","findGlobalVersions","findMigrationDir","findOne","findVersions","migrate","migrateDown","migrateFresh","migrateRefresh","migrateReset","migrateStatus","operatorMap","queryDrafts","buildDrizzleRelations","buildRawSchema","beginTransaction","commitTransaction","rollbackTransaction","updateGlobal","updateGlobalVersion","updateMany","updateOne","updateVersion","upsertRow","buildCreateMigration","buildIndexName","createSchemaGenerator","executeSchemaHooks","extendDrizzleTable","hasLocalesTable","pushDevSchema","validateExistingBlockIsIdentical"],"mappings":"AAAA,SAASA,KAAK,QAAQ,aAAY;AAClC,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,MAAM,QAAQ,cAAa;AACpC,SAASC,YAAY,QAAQ,oBAAmB;AAChD,S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AAsC;AAC5E,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,eAAe,QAAQ,iCAAgC;AAChE,SAASC,aAAa,QAAQ,+BAA8B;AAC5D,SAASC,gCAAgC,QAAQ,kDAAiD"}
|
package/dist/updateGlobal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { UpdateGlobalArgs } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function updateGlobal<T extends Record<string, unknown>>(this: DrizzleAdapter, { slug, data, req, select }: UpdateGlobalArgs): Promise<T>;
|
|
3
|
+
export declare function updateGlobal<T extends Record<string, unknown>>(this: DrizzleAdapter, { slug, data, req, select, returning }: UpdateGlobalArgs): Promise<T>;
|
|
4
4
|
//# sourceMappingURL=updateGlobal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,cAAc,EACpB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"updateGlobal.d.ts","sourceRoot":"","sources":["../src/updateGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAKhD,wBAAsB,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,IAAI,EAAE,cAAc,EACpB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,gBAAgB,GACvD,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
|
package/dist/updateGlobal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import toSnakeCase from 'to-snake-case';
|
|
2
2
|
import { upsertRow } from './upsertRow/index.js';
|
|
3
3
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
4
|
-
export async function updateGlobal({ slug, data, req, select }) {
|
|
4
|
+
export async function updateGlobal({ slug, data, req, select, returning }) {
|
|
5
5
|
const db = await getTransaction(this, req);
|
|
6
6
|
const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
|
|
7
7
|
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
|
|
@@ -19,8 +19,12 @@ export async function updateGlobal({ slug, data, req, select }) {
|
|
|
19
19
|
fields: globalConfig.flattenedFields,
|
|
20
20
|
req,
|
|
21
21
|
select,
|
|
22
|
-
tableName
|
|
22
|
+
tableName,
|
|
23
|
+
ignoreResult: returning === false
|
|
23
24
|
});
|
|
25
|
+
if (returning === false) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
24
28
|
result.globalType = slug;
|
|
25
29
|
return result;
|
|
26
30
|
}
|
package/dist/updateGlobal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { UpdateGlobalArgs } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function updateGlobal<T extends Record<string, unknown>>(\n this: DrizzleAdapter,\n { slug, data, req, select }: UpdateGlobalArgs,\n): Promise<T> {\n const db = await getTransaction(this, req)\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const existingGlobal = await db.query[tableName].findFirst({})\n\n const result = await upsertRow<{ globalType: string } & T>({\n ...(existingGlobal ? { id: existingGlobal.id, operation: 'update' } : { operation: 'create' }),\n adapter: this,\n data,\n db,\n fields: globalConfig.flattenedFields,\n req,\n select,\n tableName,\n })\n\n result.globalType = slug\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","getTransaction","updateGlobal","slug","data","req","select","db","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","existingGlobal","query","findFirst","result","id","operation","adapter","fields","flattenedFields","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAoB;
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobal.ts"],"sourcesContent":["import type { UpdateGlobalArgs } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function updateGlobal<T extends Record<string, unknown>>(\n this: DrizzleAdapter,\n { slug, data, req, select, returning }: UpdateGlobalArgs,\n): Promise<T> {\n const db = await getTransaction(this, req)\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug))\n\n const existingGlobal = await db.query[tableName].findFirst({})\n\n const result = await upsertRow<{ globalType: string } & T>({\n ...(existingGlobal ? { id: existingGlobal.id, operation: 'update' } : { operation: 'create' }),\n adapter: this,\n data,\n db,\n fields: globalConfig.flattenedFields,\n req,\n select,\n tableName,\n ignoreResult: returning === false,\n })\n\n if (returning === false) {\n return null\n }\n\n result.globalType = slug\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","getTransaction","updateGlobal","slug","data","req","select","returning","db","globalConfig","payload","globals","config","find","tableName","tableNameMap","get","existingGlobal","query","findFirst","result","id","operation","adapter","fields","flattenedFields","ignoreResult","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,EAAEC,SAAS,EAAoB;IAExD,MAAMC,KAAK,MAAMP,eAAe,IAAI,EAAEI;IACtC,MAAMI,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOT,IAAI,KAAKA;IAClF,MAAMW,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACjB,YAAYU,aAAaN,IAAI;IAErE,MAAMc,iBAAiB,MAAMT,GAAGU,KAAK,CAACJ,UAAU,CAACK,SAAS,CAAC,CAAC;IAE5D,MAAMC,SAAS,MAAMpB,UAAsC;QACzD,GAAIiB,iBAAiB;YAAEI,IAAIJ,eAAeI,EAAE;YAAEC,WAAW;QAAS,IAAI;YAAEA,WAAW;QAAS,CAAC;QAC7FC,SAAS,IAAI;QACbnB;QACAI;QACAgB,QAAQf,aAAagB,eAAe;QACpCpB;QACAC;QACAQ;QACAY,cAAcnB,cAAc;IAC9B;IAEA,IAAIA,cAAc,OAAO;QACvB,OAAO;IACT;IAEAa,OAAOO,UAAU,GAAGxB;IAEpB,OAAOiB;AACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TypeWithID, TypeWithVersion, UpdateGlobalVersionArgs } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function updateGlobalVersion<T extends TypeWithID>(this: DrizzleAdapter, { id, global, locale, req, select, versionData, where: whereArg }: UpdateGlobalVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
|
3
|
+
export declare function updateGlobalVersion<T extends TypeWithID>(this: DrizzleAdapter, { id, global, locale, req, select, versionData, where: whereArg, returning, }: UpdateGlobalVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
|
4
4
|
//# sourceMappingURL=updateGlobalVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,eAAe,EACf,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,cAAc,EACpB,
|
|
1
|
+
{"version":3,"file":"updateGlobalVersion.d.ts","sourceRoot":"","sources":["../src/updateGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,eAAe,EACf,uBAAuB,EACxB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,cAAc,EACpB,EACE,EAAE,EACF,MAAM,EACN,MAAM,EACN,GAAG,EACH,MAAM,EACN,WAAW,EACX,KAAK,EAAE,QAAQ,EACf,SAAS,GACV,EAAE,uBAAuB,CAAC,CAAC,CAAC,+BAyC9B"}
|
|
@@ -3,7 +3,7 @@ import toSnakeCase from 'to-snake-case';
|
|
|
3
3
|
import buildQuery from './queries/buildQuery.js';
|
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
|
5
5
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
6
|
-
export async function updateGlobalVersion({ id, global, locale, req, select, versionData, where: whereArg }) {
|
|
6
|
+
export async function updateGlobalVersion({ id, global, locale, req, select, versionData, where: whereArg, returning }) {
|
|
7
7
|
const db = await getTransaction(this, req);
|
|
8
8
|
const globalConfig = this.payload.globals.config.find(({ slug })=>slug === global);
|
|
9
9
|
const whereToUse = whereArg || {
|
|
@@ -30,8 +30,12 @@ export async function updateGlobalVersion({ id, global, locale, req, select, ver
|
|
|
30
30
|
req,
|
|
31
31
|
select,
|
|
32
32
|
tableName,
|
|
33
|
-
where
|
|
33
|
+
where,
|
|
34
|
+
ignoreResult: returning === false
|
|
34
35
|
});
|
|
36
|
+
if (returning === false) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
35
39
|
return result;
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type {\n SanitizedGlobalConfig,\n TypeWithID,\n TypeWithVersion,\n UpdateGlobalVersionArgs,\n} from 'payload'\n\nimport { buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {
|
|
1
|
+
{"version":3,"sources":["../src/updateGlobalVersion.ts"],"sourcesContent":["import type {\n SanitizedGlobalConfig,\n TypeWithID,\n TypeWithVersion,\n UpdateGlobalVersionArgs,\n} from 'payload'\n\nimport { buildVersionGlobalFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function updateGlobalVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {\n id,\n global,\n locale,\n req,\n select,\n versionData,\n where: whereArg,\n returning,\n }: UpdateGlobalVersionArgs<T>,\n) {\n const db = await getTransaction(this, req)\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const whereToUse = whereArg || { id: { equals: id } }\n\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(globalConfig.slug)}${this.versionsSuffix}`,\n )\n\n const fields = buildVersionGlobalFields(this.payload.config, globalConfig, true)\n\n const { where } = buildQuery({\n adapter: this,\n fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n id,\n adapter: this,\n data: versionData,\n db,\n fields,\n operation: 'update',\n req,\n select,\n tableName,\n where,\n ignoreResult: returning === false,\n })\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["buildVersionGlobalFields","toSnakeCase","buildQuery","upsertRow","getTransaction","updateGlobalVersion","id","global","locale","req","select","versionData","where","whereArg","returning","db","globalConfig","payload","globals","config","find","slug","whereToUse","equals","tableName","tableNameMap","get","versionsSuffix","fields","adapter","result","data","operation","ignoreResult"],"mappings":"AAOA,SAASA,wBAAwB,QAAQ,UAAS;AAClD,OAAOC,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,oBAEpB,EACEC,EAAE,EACFC,MAAM,EACNC,MAAM,EACNC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,OAAOC,QAAQ,EACfC,SAAS,EACkB;IAE7B,MAAMC,KAAK,MAAMX,eAAe,IAAI,EAAEK;IACtC,MAAMO,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASd;IAEzB,MAAMe,aAAaT,YAAY;QAAEP,IAAI;YAAEiB,QAAQjB;QAAG;IAAE;IAEpD,MAAMkB,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEzB,YAAYe,aAAaK,IAAI,IAAI,IAAI,CAACM,cAAc,EAAE;IAG5D,MAAMC,SAAS5B,yBAAyB,IAAI,CAACiB,OAAO,CAACE,MAAM,EAAEH,cAAc;IAE3E,MAAM,EAAEJ,KAAK,EAAE,GAAGV,WAAW;QAC3B2B,SAAS,IAAI;QACbD;QACApB;QACAgB;QACAZ,OAAOU;IACT;IAEA,MAAMQ,SAAS,MAAM3B,UAA8B;QACjDG;QACAuB,SAAS,IAAI;QACbE,MAAMpB;QACNI;QACAa;QACAI,WAAW;QACXvB;QACAC;QACAc;QACAZ;QACAqB,cAAcnB,cAAc;IAC9B;IAEA,IAAIA,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAOgB;AACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updateMany.d.ts","sourceRoot":"","sources":["../src/updateMany.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAWzC,eAAO,MAAM,UAAU,EAAE,UA8FxB,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import toSnakeCase from 'to-snake-case';
|
|
2
|
+
import buildQuery from './queries/buildQuery.js';
|
|
3
|
+
import { selectDistinct } from './queries/selectDistinct.js';
|
|
4
|
+
import { upsertRow } from './upsertRow/index.js';
|
|
5
|
+
import { getTransaction } from './utilities/getTransaction.js';
|
|
6
|
+
export const updateMany = async function updateMany({ collection: collectionSlug, data, joins: joinQuery, limit, locale, req, returning, select, where: whereToUse }) {
|
|
7
|
+
const db = await getTransaction(this, req);
|
|
8
|
+
const collection = this.payload.collections[collectionSlug].config;
|
|
9
|
+
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
|
10
|
+
const { joins, selectFields, where } = buildQuery({
|
|
11
|
+
adapter: this,
|
|
12
|
+
fields: collection.flattenedFields,
|
|
13
|
+
locale,
|
|
14
|
+
tableName,
|
|
15
|
+
where: whereToUse
|
|
16
|
+
});
|
|
17
|
+
let idsToUpdate = [];
|
|
18
|
+
const selectDistinctResult = await selectDistinct({
|
|
19
|
+
adapter: this,
|
|
20
|
+
db,
|
|
21
|
+
joins,
|
|
22
|
+
selectFields,
|
|
23
|
+
tableName,
|
|
24
|
+
where
|
|
25
|
+
});
|
|
26
|
+
if (selectDistinctResult?.[0]?.id) {
|
|
27
|
+
idsToUpdate = selectDistinctResult?.map((doc)=>doc.id);
|
|
28
|
+
// If id wasn't passed but `where` without any joins, retrieve it with findFirst
|
|
29
|
+
} else if (whereToUse && !joins.length) {
|
|
30
|
+
const _db = db;
|
|
31
|
+
const table = this.tables[tableName];
|
|
32
|
+
const docsToUpdate = typeof limit === 'number' && limit > 0 ? await _db.select({
|
|
33
|
+
id: table.id
|
|
34
|
+
}).from(table).where(where).limit(limit) : await _db.select({
|
|
35
|
+
id: table.id
|
|
36
|
+
}).from(table).where(where);
|
|
37
|
+
idsToUpdate = docsToUpdate?.map((doc)=>doc.id);
|
|
38
|
+
}
|
|
39
|
+
if (!idsToUpdate.length) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const results = [];
|
|
43
|
+
// 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.
|
|
44
|
+
for (const idToUpdate of idsToUpdate){
|
|
45
|
+
const result = await upsertRow({
|
|
46
|
+
id: idToUpdate,
|
|
47
|
+
adapter: this,
|
|
48
|
+
data,
|
|
49
|
+
db,
|
|
50
|
+
fields: collection.flattenedFields,
|
|
51
|
+
ignoreResult: returning === false,
|
|
52
|
+
joinQuery,
|
|
53
|
+
operation: 'update',
|
|
54
|
+
req,
|
|
55
|
+
select,
|
|
56
|
+
tableName
|
|
57
|
+
});
|
|
58
|
+
results.push(result);
|
|
59
|
+
}
|
|
60
|
+
if (returning === false) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return results;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=updateMany.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/updateMany.ts"],"sourcesContent":["import type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { UpdateMany } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const updateMany: UpdateMany = async function updateMany(\n this: DrizzleAdapter,\n {\n collection: collectionSlug,\n data,\n joins: joinQuery,\n limit,\n locale,\n req,\n returning,\n select,\n where: whereToUse,\n },\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n\n const { joins, selectFields, where } = buildQuery({\n adapter: this,\n fields: collection.flattenedFields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n let idsToUpdate: (number | string)[] = []\n\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n idsToUpdate = selectDistinctResult?.map((doc) => doc.id)\n\n // If id wasn't passed but `where` without any joins, retrieve it with findFirst\n } else if (whereToUse && !joins.length) {\n const _db = db as LibSQLDatabase\n\n const table = this.tables[tableName]\n\n const docsToUpdate =\n typeof limit === 'number' && limit > 0\n ? await _db\n .select({\n id: table.id,\n })\n .from(table)\n .where(where)\n .limit(limit)\n : await _db\n .select({\n id: table.id,\n })\n .from(table)\n .where(where)\n\n idsToUpdate = docsToUpdate?.map((doc) => doc.id)\n }\n\n if (!idsToUpdate.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 idToUpdate of idsToUpdate) {\n const result = await upsertRow({\n id: idToUpdate,\n adapter: this,\n data,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n joinQuery,\n operation: 'update',\n req,\n select,\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","buildQuery","selectDistinct","upsertRow","getTransaction","updateMany","collection","collectionSlug","data","joins","joinQuery","limit","locale","req","returning","select","where","whereToUse","db","payload","collections","config","tableName","tableNameMap","get","slug","selectFields","adapter","fields","flattenedFields","idsToUpdate","selectDistinctResult","id","map","doc","length","_db","table","tables","docsToUpdate","from","results","idToUpdate","result","ignoreResult","operation","push"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EACEC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,OAAOC,SAAS,EAChBC,KAAK,EACLC,MAAM,EACNC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,OAAOC,UAAU,EAClB;IAED,MAAMC,KAAK,MAAMd,eAAe,IAAI,EAAES;IACtC,MAAMP,aAAa,IAAI,CAACa,OAAO,CAACC,WAAW,CAACb,eAAe,CAACc,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACxB,YAAYM,WAAWmB,IAAI;IAEnE,MAAM,EAAEhB,KAAK,EAAEiB,YAAY,EAAEV,KAAK,EAAE,GAAGf,WAAW;QAChD0B,SAAS,IAAI;QACbC,QAAQtB,WAAWuB,eAAe;QAClCjB;QACAU;QACAN,OAAOC;IACT;IAEA,IAAIa,cAAmC,EAAE;IAEzC,MAAMC,uBAAuB,MAAM7B,eAAe;QAChDyB,SAAS,IAAI;QACbT;QACAT;QACAiB;QACAJ;QACAN;IACF;IAEA,IAAIe,sBAAsB,CAAC,EAAE,EAAEC,IAAI;QACjCF,cAAcC,sBAAsBE,IAAI,CAACC,MAAQA,IAAIF,EAAE;IAEvD,gFAAgF;IAClF,OAAO,IAAIf,cAAc,CAACR,MAAM0B,MAAM,EAAE;QACtC,MAAMC,MAAMlB;QAEZ,MAAMmB,QAAQ,IAAI,CAACC,MAAM,CAAChB,UAAU;QAEpC,MAAMiB,eACJ,OAAO5B,UAAU,YAAYA,QAAQ,IACjC,MAAMyB,IACHrB,MAAM,CAAC;YACNiB,IAAIK,MAAML,EAAE;QACd,GACCQ,IAAI,CAACH,OACLrB,KAAK,CAACA,OACNL,KAAK,CAACA,SACT,MAAMyB,IACHrB,MAAM,CAAC;YACNiB,IAAIK,MAAML,EAAE;QACd,GACCQ,IAAI,CAACH,OACLrB,KAAK,CAACA;QAEfc,cAAcS,cAAcN,IAAI,CAACC,MAAQA,IAAIF,EAAE;IACjD;IAEA,IAAI,CAACF,YAAYK,MAAM,EAAE;QACvB,OAAO,EAAE;IACX;IAEA,MAAMM,UAAU,EAAE;IAElB,yHAAyH;IACzH,KAAK,MAAMC,cAAcZ,YAAa;QACpC,MAAMa,SAAS,MAAMxC,UAAU;YAC7B6B,IAAIU;YACJf,SAAS,IAAI;YACbnB;YACAU;YACAU,QAAQtB,WAAWuB,eAAe;YAClCe,cAAc9B,cAAc;YAC5BJ;YACAmC,WAAW;YACXhC;YACAE;YACAO;QACF;QACAmB,QAAQK,IAAI,CAACH;IACf;IAEA,IAAI7B,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAO2B;AACT,EAAC"}
|
package/dist/updateOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAWxC,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAWxC,eAAO,MAAM,SAAS,EAAE,SA0EvB,CAAA"}
|
package/dist/updateOne.js
CHANGED
|
@@ -3,7 +3,7 @@ import buildQuery from './queries/buildQuery.js';
|
|
|
3
3
|
import { selectDistinct } from './queries/selectDistinct.js';
|
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
|
5
5
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
6
|
-
export const updateOne = async function updateOne({ id, collection: collectionSlug, data, joins: joinQuery, locale, req, select, where: whereArg }) {
|
|
6
|
+
export const updateOne = async function updateOne({ id, collection: collectionSlug, data, joins: joinQuery, locale, req, select, where: whereArg, returning }) {
|
|
7
7
|
const db = await getTransaction(this, req);
|
|
8
8
|
const collection = this.payload.collections[collectionSlug].config;
|
|
9
9
|
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
|
@@ -57,8 +57,12 @@ export const updateOne = async function updateOne({ id, collection: collectionSl
|
|
|
57
57
|
operation: 'update',
|
|
58
58
|
req,
|
|
59
59
|
select,
|
|
60
|
-
tableName
|
|
60
|
+
tableName,
|
|
61
|
+
ignoreResult: returning === false
|
|
61
62
|
});
|
|
63
|
+
if (returning === false) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
62
66
|
return result;
|
|
63
67
|
};
|
|
64
68
|
|
package/dist/updateOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { UpdateOne } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: DrizzleAdapter,\n {
|
|
1
|
+
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { UpdateOne } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: DrizzleAdapter,\n {\n id,\n collection: collectionSlug,\n data,\n joins: joinQuery,\n locale,\n req,\n select,\n where: whereArg,\n returning,\n },\n) {\n const db = await getTransaction(this, req)\n const collection = this.payload.collections[collectionSlug].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n const whereToUse = whereArg || { id: { equals: id } }\n let idToUpdate = id\n\n const { joins, selectFields, where } = buildQuery({\n adapter: this,\n fields: collection.flattenedFields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n // selectDistinct will only return if there are joins\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n chainedMethods: [{ args: [1], method: 'limit' }],\n db,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n idToUpdate = selectDistinctResult?.[0]?.id\n // If id wasn't passed but `where` without any joins, retrieve it with findFirst\n } else if (whereArg && !joins.length) {\n const table = this.tables[tableName]\n\n const docsToUpdate = await (db as LibSQLDatabase)\n .select({\n id: table.id,\n })\n .from(table)\n .where(where)\n .limit(1)\n idToUpdate = docsToUpdate?.[0]?.id\n }\n\n const result = await upsertRow({\n id: idToUpdate,\n adapter: this,\n data,\n db,\n fields: collection.flattenedFields,\n joinQuery,\n operation: 'update',\n req,\n select,\n tableName,\n ignoreResult: returning === false,\n })\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["toSnakeCase","buildQuery","selectDistinct","upsertRow","getTransaction","updateOne","id","collection","collectionSlug","data","joins","joinQuery","locale","req","select","where","whereArg","returning","db","payload","collections","config","tableName","tableNameMap","get","slug","whereToUse","equals","idToUpdate","selectFields","adapter","fields","flattenedFields","selectDistinctResult","chainedMethods","args","method","length","table","tables","docsToUpdate","from","limit","result","operation","ignoreResult"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EACEC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,OAAOC,SAAS,EAChBC,MAAM,EACNC,GAAG,EACHC,MAAM,EACNC,OAAOC,QAAQ,EACfC,SAAS,EACV;IAED,MAAMC,KAAK,MAAMd,eAAe,IAAI,EAAES;IACtC,MAAMN,aAAa,IAAI,CAACY,OAAO,CAACC,WAAW,CAACZ,eAAe,CAACa,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACxB,YAAYO,WAAWkB,IAAI;IACnE,MAAMC,aAAaV,YAAY;QAAEV,IAAI;YAAEqB,QAAQrB;QAAG;IAAE;IACpD,IAAIsB,aAAatB;IAEjB,MAAM,EAAEI,KAAK,EAAEmB,YAAY,EAAEd,KAAK,EAAE,GAAGd,WAAW;QAChD6B,SAAS,IAAI;QACbC,QAAQxB,WAAWyB,eAAe;QAClCpB;QACAU;QACAP,OAAOW;IACT;IAEA,qDAAqD;IACrD,MAAMO,uBAAuB,MAAM/B,eAAe;QAChD4B,SAAS,IAAI;QACbI,gBAAgB;YAAC;gBAAEC,MAAM;oBAAC;iBAAE;gBAAEC,QAAQ;YAAQ;SAAE;QAChDlB;QACAR;QACAmB;QACAP;QACAP;IACF;IAEA,IAAIkB,sBAAsB,CAAC,EAAE,EAAE3B,IAAI;QACjCsB,aAAaK,sBAAsB,CAAC,EAAE,EAAE3B;IACxC,gFAAgF;IAClF,OAAO,IAAIU,YAAY,CAACN,MAAM2B,MAAM,EAAE;QACpC,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACjB,UAAU;QAEpC,MAAMkB,eAAe,MAAM,AAACtB,GACzBJ,MAAM,CAAC;YACNR,IAAIgC,MAAMhC,EAAE;QACd,GACCmC,IAAI,CAACH,OACLvB,KAAK,CAACA,OACN2B,KAAK,CAAC;QACTd,aAAaY,cAAc,CAAC,EAAE,EAAElC;IAClC;IAEA,MAAMqC,SAAS,MAAMxC,UAAU;QAC7BG,IAAIsB;QACJE,SAAS,IAAI;QACbrB;QACAS;QACAa,QAAQxB,WAAWyB,eAAe;QAClCrB;QACAiC,WAAW;QACX/B;QACAC;QACAQ;QACAuB,cAAc5B,cAAc;IAC9B;IAEA,IAAIA,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAO0B;AACT,EAAC"}
|
package/dist/updateVersion.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { TypeWithID, TypeWithVersion, UpdateVersionArgs } from 'payload';
|
|
2
2
|
import type { DrizzleAdapter } from './types.js';
|
|
3
|
-
export declare function updateVersion<T extends TypeWithID>(this: DrizzleAdapter, { id, collection, locale, req, select, versionData, where: whereArg }: UpdateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
|
3
|
+
export declare function updateVersion<T extends TypeWithID>(this: DrizzleAdapter, { id, collection, locale, req, select, versionData, where: whereArg, returning, }: UpdateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
|
4
4
|
//# sourceMappingURL=updateVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,cAAc,EACpB,
|
|
1
|
+
{"version":3,"file":"updateVersion.d.ts","sourceRoot":"","sources":["../src/updateVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,SAAS,CAAA;AAKhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAMhD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,cAAc,EACpB,EACE,EAAE,EACF,UAAU,EACV,MAAM,EACN,GAAG,EACH,MAAM,EACN,WAAW,EACX,KAAK,EAAE,QAAQ,EACf,SAAS,GACV,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAuCxB"}
|
package/dist/updateVersion.js
CHANGED
|
@@ -3,7 +3,7 @@ import toSnakeCase from 'to-snake-case';
|
|
|
3
3
|
import buildQuery from './queries/buildQuery.js';
|
|
4
4
|
import { upsertRow } from './upsertRow/index.js';
|
|
5
5
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
6
|
-
export async function updateVersion({ id, collection, locale, req, select, versionData, where: whereArg }) {
|
|
6
|
+
export async function updateVersion({ id, collection, locale, req, select, versionData, where: whereArg, returning }) {
|
|
7
7
|
const db = await getTransaction(this, req);
|
|
8
8
|
const collectionConfig = this.payload.collections[collection].config;
|
|
9
9
|
const whereToUse = whereArg || {
|
|
@@ -31,8 +31,12 @@ export async function updateVersion({ id, collection, locale, req, select, versi
|
|
|
31
31
|
req,
|
|
32
32
|
select,
|
|
33
33
|
tableName,
|
|
34
|
-
where
|
|
34
|
+
where,
|
|
35
|
+
ignoreResult: returning === false
|
|
35
36
|
});
|
|
37
|
+
if (returning === false) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
36
40
|
return result;
|
|
37
41
|
}
|
|
38
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type {\n SanitizedCollectionConfig,\n TypeWithID,\n TypeWithVersion,\n UpdateVersionArgs,\n} from 'payload'\n\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function updateVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {
|
|
1
|
+
{"version":3,"sources":["../src/updateVersion.ts"],"sourcesContent":["import type {\n SanitizedCollectionConfig,\n TypeWithID,\n TypeWithVersion,\n UpdateVersionArgs,\n} from 'payload'\n\nimport { buildVersionCollectionFields } from 'payload'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport buildQuery from './queries/buildQuery.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { getTransaction } from './utilities/getTransaction.js'\n\nexport async function updateVersion<T extends TypeWithID>(\n this: DrizzleAdapter,\n {\n id,\n collection,\n locale,\n req,\n select,\n versionData,\n where: whereArg,\n returning,\n }: UpdateVersionArgs<T>,\n) {\n const db = await getTransaction(this, req)\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const whereToUse = whereArg || { id: { equals: id } }\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n\n const fields = buildVersionCollectionFields(this.payload.config, collectionConfig, true)\n\n const { where } = buildQuery({\n adapter: this,\n fields,\n locale,\n tableName,\n where: whereToUse,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n id,\n adapter: this,\n data: versionData,\n db,\n fields,\n joinQuery: false,\n operation: 'update',\n req,\n select,\n tableName,\n where,\n ignoreResult: returning === false,\n })\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["buildVersionCollectionFields","toSnakeCase","buildQuery","upsertRow","getTransaction","updateVersion","id","collection","locale","req","select","versionData","where","whereArg","returning","db","collectionConfig","payload","collections","config","whereToUse","equals","tableName","tableNameMap","get","slug","versionsSuffix","fields","adapter","result","data","joinQuery","operation","ignoreResult"],"mappings":"AAOA,SAASA,4BAA4B,QAAQ,UAAS;AACtD,OAAOC,iBAAiB,gBAAe;AAIvC,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,cAAc,QAAQ,gCAA+B;AAE9D,OAAO,eAAeC,cAEpB,EACEC,EAAE,EACFC,UAAU,EACVC,MAAM,EACNC,GAAG,EACHC,MAAM,EACNC,WAAW,EACXC,OAAOC,QAAQ,EACfC,SAAS,EACY;IAEvB,MAAMC,KAAK,MAAMX,eAAe,IAAI,EAAEK;IACtC,MAAMO,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACX,WAAW,CAACY,MAAM;IAC/F,MAAMC,aAAaP,YAAY;QAAEP,IAAI;YAAEe,QAAQf;QAAG;IAAE;IACpD,MAAMgB,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEvB,YAAYe,iBAAiBS,IAAI,IAAI,IAAI,CAACC,cAAc,EAAE;IAGhE,MAAMC,SAAS3B,6BAA6B,IAAI,CAACiB,OAAO,CAACE,MAAM,EAAEH,kBAAkB;IAEnF,MAAM,EAAEJ,KAAK,EAAE,GAAGV,WAAW;QAC3B0B,SAAS,IAAI;QACbD;QACAnB;QACAc;QACAV,OAAOQ;IACT;IAEA,MAAMS,SAAS,MAAM1B,UAA8B;QACjDG;QACAsB,SAAS,IAAI;QACbE,MAAMnB;QACNI;QACAY;QACAI,WAAW;QACXC,WAAW;QACXvB;QACAC;QACAY;QACAV;QACAqB,cAAcnB,cAAc;IAC9B;IAEA,IAAIA,cAAc,OAAO;QACvB,OAAO;IACT;IAEA,OAAOe;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAStC,eAAO,MAAM,SAAS,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,yIAkB3E,IAAI,KAAG,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/upsertRow/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAStC,eAAO,MAAM,SAAS,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,yIAkB3E,IAAI,KAAG,OAAO,CAAC,CAAC,CAmblB,CAAA"}
|
package/dist/upsertRow/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/upsertRow/index.ts"],"sourcesContent":["import type { TypeWithID } from 'payload'\n\nimport { eq } from 'drizzle-orm'\nimport { ValidationError } from 'payload'\n\nimport type { BlockRowToInsert } from '../transform/write/types.js'\nimport type { Args } from './types.js'\n\nimport { buildFindManyArgs } from '../find/buildFindManyArgs.js'\nimport { transform } from '../transform/read/index.js'\nimport { transformForWrite } from '../transform/write/index.js'\nimport { deleteExistingArrayRows } from './deleteExistingArrayRows.js'\nimport { deleteExistingRowsByPath } from './deleteExistingRowsByPath.js'\nimport { insertArrays } from './insertArrays.js'\n\nexport const upsertRow = async <T extends Record<string, unknown> | TypeWithID>({\n id,\n adapter,\n data,\n db,\n fields,\n ignoreResult,\n // TODO:\n // When we support joins for write operations (create/update) - pass collectionSlug to the buildFindManyArgs\n // Make a new argument in upsertRow.ts and pass the slug from every operation.\n joinQuery: _joinQuery,\n operation,\n path = '',\n req,\n select,\n tableName,\n upsertTarget,\n where,\n}: Args): Promise<T> => {\n // Split out the incoming data into the corresponding:\n // base row, locales, relationships, blocks, and arrays\n const rowToInsert = transformForWrite({\n adapter,\n data,\n fields,\n path,\n tableName,\n })\n\n // First, we insert the main row\n let insertedRow: Record<string, unknown>\n\n try {\n if (operation === 'update') {\n const target = upsertTarget || adapter.tables[tableName].id\n\n if (id) {\n rowToInsert.row.id = id\n ;[insertedRow] = await adapter.insert({\n db,\n onConflictDoUpdate: { set: rowToInsert.row, target },\n tableName,\n values: rowToInsert.row,\n })\n } else {\n ;[insertedRow] = await adapter.insert({\n db,\n onConflictDoUpdate: { set: rowToInsert.row, target, where },\n tableName,\n values: rowToInsert.row,\n })\n }\n } else {\n ;[insertedRow] = await adapter.insert({\n db,\n tableName,\n values: rowToInsert.row,\n })\n }\n\n const localesToInsert: Record<string, unknown>[] = []\n const relationsToInsert: Record<string, unknown>[] = []\n const textsToInsert: Record<string, unknown>[] = []\n const numbersToInsert: Record<string, unknown>[] = []\n const blocksToInsert: { [blockType: string]: BlockRowToInsert[] } = {}\n const selectsToInsert: { [selectTableName: string]: Record<string, unknown>[] } = {}\n\n // If there are locale rows with data, add the parent and locale to each\n if (Object.keys(rowToInsert.locales).length > 0) {\n Object.entries(rowToInsert.locales).forEach(([locale, localeRow]) => {\n localeRow._parentID = insertedRow.id\n localeRow._locale = locale\n localesToInsert.push(localeRow)\n })\n }\n\n // If there are relationships, add parent to each\n if (rowToInsert.relationships.length > 0) {\n rowToInsert.relationships.forEach((relation) => {\n relation.parent = insertedRow.id\n relationsToInsert.push(relation)\n })\n }\n\n // If there are texts, add parent to each\n if (rowToInsert.texts.length > 0) {\n rowToInsert.texts.forEach((textRow) => {\n textRow.parent = insertedRow.id\n textsToInsert.push(textRow)\n })\n }\n\n // If there are numbers, add parent to each\n if (rowToInsert.numbers.length > 0) {\n rowToInsert.numbers.forEach((numberRow) => {\n numberRow.parent = insertedRow.id\n numbersToInsert.push(numberRow)\n })\n }\n\n // If there are selects, add parent to each, and then\n // store by table name and rows\n if (Object.keys(rowToInsert.selects).length > 0) {\n Object.entries(rowToInsert.selects).forEach(([selectTableName, selectRows]) => {\n selectsToInsert[selectTableName] = []\n\n selectRows.forEach((row) => {\n if (typeof row.parent === 'undefined') {\n row.parent = insertedRow.id\n }\n\n selectsToInsert[selectTableName].push(row)\n })\n })\n }\n\n // If there are blocks, add parent to each, and then\n // store by table name and rows\n Object.keys(rowToInsert.blocks).forEach((blockName) => {\n rowToInsert.blocks[blockName].forEach((blockRow) => {\n blockRow.row._parentID = insertedRow.id\n if (!blocksToInsert[blockName]) {\n blocksToInsert[blockName] = []\n }\n if (blockRow.row.uuid) {\n delete blockRow.row.uuid\n }\n blocksToInsert[blockName].push(blockRow)\n })\n })\n\n // //////////////////////////////////\n // INSERT LOCALES\n // //////////////////////////////////\n\n if (localesToInsert.length > 0) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n const localeTable = adapter.tables[`${tableName}${adapter.localesSuffix}`]\n\n if (operation === 'update') {\n await adapter.deleteWhere({\n db,\n tableName: localeTableName,\n where: eq(localeTable._parentID, insertedRow.id),\n })\n }\n\n await adapter.insert({\n db,\n tableName: localeTableName,\n values: localesToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT RELATIONSHIPS\n // //////////////////////////////////\n\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: [...relationsToInsert, ...rowToInsert.relationshipsToDelete],\n tableName: relationshipsTableName,\n })\n }\n\n if (relationsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: relationshipsTableName,\n values: relationsToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT hasMany TEXTS\n // //////////////////////////////////\n\n const textsTableName = `${tableName}_texts`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: textsToInsert,\n tableName: textsTableName,\n })\n }\n\n if (textsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: textsTableName,\n values: textsToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT hasMany NUMBERS\n // //////////////////////////////////\n\n const numbersTableName = `${tableName}_numbers`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: numbersToInsert,\n tableName: numbersTableName,\n })\n }\n\n if (numbersToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: numbersTableName,\n values: numbersToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT BLOCKS\n // //////////////////////////////////\n\n const insertedBlockRows: Record<string, Record<string, unknown>[]> = {}\n\n if (operation === 'update') {\n for (const blockName of rowToInsert.blocksToDelete) {\n const blockTableName = adapter.tableNameMap.get(`${tableName}_blocks_${blockName}`)\n const blockTable = adapter.tables[blockTableName]\n await adapter.deleteWhere({\n db,\n tableName: blockTableName,\n where: eq(blockTable._parentID, insertedRow.id),\n })\n }\n }\n\n // When versions are enabled, this is used to track mapping between blocks/arrays ObjectID to their numeric generated representation, then we use it for nested to arrays/blocks select hasMany in versions.\n const arraysBlocksUUIDMap: Record<string, number | string> = {}\n\n for (const [blockName, blockRows] of Object.entries(blocksToInsert)) {\n const blockTableName = adapter.tableNameMap.get(`${tableName}_blocks_${blockName}`)\n insertedBlockRows[blockName] = await adapter.insert({\n db,\n tableName: blockTableName,\n values: blockRows.map(({ row }) => row),\n })\n\n insertedBlockRows[blockName].forEach((row, i) => {\n blockRows[i].row = row\n if (\n typeof row._uuid === 'string' &&\n (typeof row.id === 'string' || typeof row.id === 'number')\n ) {\n arraysBlocksUUIDMap[row._uuid] = row.id\n }\n })\n\n const blockLocaleIndexMap: number[] = []\n\n const blockLocaleRowsToInsert = blockRows.reduce((acc, blockRow, i) => {\n if (Object.entries(blockRow.locales).length > 0) {\n Object.entries(blockRow.locales).forEach(([blockLocale, blockLocaleData]) => {\n if (Object.keys(blockLocaleData).length > 0) {\n blockLocaleData._parentID = blockRow.row.id\n blockLocaleData._locale = blockLocale\n acc.push(blockLocaleData)\n blockLocaleIndexMap.push(i)\n }\n })\n }\n\n return acc\n }, [])\n\n if (blockLocaleRowsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: `${blockTableName}${adapter.localesSuffix}`,\n values: blockLocaleRowsToInsert,\n })\n }\n\n await insertArrays({\n adapter,\n arrays: blockRows.map(({ arrays }) => arrays),\n db,\n parentRows: insertedBlockRows[blockName],\n uuidMap: arraysBlocksUUIDMap,\n })\n }\n\n // //////////////////////////////////\n // INSERT ARRAYS RECURSIVELY\n // //////////////////////////////////\n\n if (operation === 'update') {\n for (const arrayTableName of Object.keys(rowToInsert.arrays)) {\n await deleteExistingArrayRows({\n adapter,\n db,\n parentID: insertedRow.id,\n tableName: arrayTableName,\n })\n }\n }\n\n await insertArrays({\n adapter,\n arrays: [rowToInsert.arrays],\n db,\n parentRows: [insertedRow],\n uuidMap: arraysBlocksUUIDMap,\n })\n\n // //////////////////////////////////\n // INSERT hasMany SELECTS\n // //////////////////////////////////\n\n for (const [selectTableName, tableRows] of Object.entries(selectsToInsert)) {\n const selectTable = adapter.tables[selectTableName]\n if (operation === 'update') {\n await adapter.deleteWhere({\n db,\n tableName: selectTableName,\n where: eq(selectTable.parent, insertedRow.id),\n })\n }\n\n if (Object.keys(arraysBlocksUUIDMap).length > 0) {\n tableRows.forEach((row: any) => {\n if (row.parent in arraysBlocksUUIDMap) {\n row.parent = arraysBlocksUUIDMap[row.parent]\n }\n })\n }\n\n if (tableRows.length) {\n await adapter.insert({\n db,\n tableName: selectTableName,\n values: tableRows,\n })\n }\n }\n\n // //////////////////////////////////\n // Error Handling\n // //////////////////////////////////\n } catch (error) {\n if (error.code === '23505') {\n let fieldName: null | string = null\n // We need to try and find the right constraint for the field but if we can't we fallback to a generic message\n if (adapter.fieldConstraints?.[tableName]) {\n if (adapter.fieldConstraints[tableName]?.[error.constraint]) {\n fieldName = adapter.fieldConstraints[tableName]?.[error.constraint]\n } else {\n const replacement = `${tableName}_`\n\n if (error.constraint.includes(replacement)) {\n const replacedConstraint = error.constraint.replace(replacement, '')\n\n if (replacedConstraint && adapter.fieldConstraints[tableName]?.[replacedConstraint]) {\n fieldName = adapter.fieldConstraints[tableName][replacedConstraint]\n }\n }\n }\n }\n\n if (!fieldName) {\n // Last case scenario we extract the key and value from the detail on the error\n const detail = error.detail\n const regex = /Key \\(([^)]+)\\)=\\(([^)]+)\\)/\n const match = detail.match(regex)\n\n if (match) {\n const key = match[1]\n\n fieldName = key\n }\n }\n\n throw new ValidationError(\n {\n id,\n errors: [\n {\n message: req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique',\n path: fieldName,\n },\n ],\n },\n req?.t,\n )\n } else {\n throw error\n }\n }\n\n if (ignoreResult) {\n return data as T\n }\n\n // //////////////////////////////////\n // RETRIEVE NEWLY UPDATED ROW\n // //////////////////////////////////\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n joinQuery: false,\n select,\n tableName,\n })\n\n findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id)\n\n const doc = await db.query[tableName].findFirst(findManyArgs)\n\n // //////////////////////////////////\n // TRANSFORM DATA\n // //////////////////////////////////\n\n const result = transform<T>({\n adapter,\n config: adapter.payload.config,\n data: doc,\n fields,\n joinQuery: false,\n })\n\n return result\n}\n"],"names":["eq","ValidationError","buildFindManyArgs","transform","transformForWrite","deleteExistingArrayRows","deleteExistingRowsByPath","insertArrays","upsertRow","id","adapter","data","db","fields","ignoreResult","joinQuery","_joinQuery","operation","path","req","select","tableName","upsertTarget","where","rowToInsert","insertedRow","target","tables","row","insert","onConflictDoUpdate","set","values","localesToInsert","relationsToInsert","textsToInsert","numbersToInsert","blocksToInsert","selectsToInsert","Object","keys","locales","length","entries","forEach","locale","localeRow","_parentID","_locale","push","relationships","relation","parent","texts","textRow","numbers","numberRow","selects","selectTableName","selectRows","blocks","blockName","blockRow","uuid","localeTableName","localesSuffix","localeTable","deleteWhere","relationshipsTableName","relationshipsSuffix","localeColumnName","parentColumnName","parentID","pathColumnName","rows","relationshipsToDelete","textsTableName","numbersTableName","insertedBlockRows","blocksToDelete","blockTableName","tableNameMap","get","blockTable","arraysBlocksUUIDMap","blockRows","map","i","_uuid","blockLocaleIndexMap","blockLocaleRowsToInsert","reduce","acc","blockLocale","blockLocaleData","arrays","parentRows","uuidMap","arrayTableName","tableRows","selectTable","error","code","fieldName","fieldConstraints","constraint","replacement","includes","replacedConstraint","replace","detail","regex","match","key","errors","message","t","findManyArgs","depth","doc","query","findFirst","result","config","payload"],"mappings":"AAEA,SAASA,EAAE,QAAQ,cAAa;AAChC,SAASC,eAAe,QAAQ,UAAS;AAKzC,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,YAAY,OAAuD,EAC9EC,EAAE,EACFC,OAAO,EACPC,IAAI,EACJC,EAAE,EACFC,MAAM,EACNC,YAAY,EACZ,QAAQ;AACR,4GAA4G;AAC5G,8EAA8E;AAC9EC,WAAWC,UAAU,EACrBC,SAAS,EACTC,OAAO,EAAE,EACTC,GAAG,EACHC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,KAAK,EACA;IACL,sDAAsD;IACtD,uDAAuD;IACvD,MAAMC,cAAcpB,kBAAkB;QACpCM;QACAC;QACAE;QACAK;QACAG;IACF;IAEA,gCAAgC;IAChC,IAAII;IAEJ,IA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A,IAAIvF,cAAc;QAChB,OAAOH;IACT;IAEA,qCAAqC;IACrC,6BAA6B;IAC7B,qCAAqC;IAErC,MAAM0G,eAAenH,kBAAkB;QACrCQ;QACA4G,OAAO;QACPzG;QACAE,WAAW;QACXK;QACAC;IACF;IAEAgG,aAAa9F,KAAK,GAAGvB,GAAGU,QAAQiB,MAAM,CAACN,UAAU,CAACZ,EAAE,EAAEgB,YAAYhB,EAAE;IAEpE,MAAM8G,MAAM,MAAM3G,GAAG4G,KAAK,CAACnG,UAAU,CAACoG,SAAS,CAACJ;IAEhD,qCAAqC;IACrC,iBAAiB;IACjB,qCAAqC;IAErC,MAAMK,SAASvH,UAAa;QAC1BO;QACAiH,QAAQjH,QAAQkH,OAAO,CAACD,MAAM;QAC9BhH,MAAM4G;QACN1G;QACAE,WAAW;IACb;IAEA,OAAO2G;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/index.ts"],"sourcesContent":["import type { TypeWithID } from 'payload'\n\nimport { eq } from 'drizzle-orm'\nimport { ValidationError } from 'payload'\n\nimport type { BlockRowToInsert } from '../transform/write/types.js'\nimport type { Args } from './types.js'\n\nimport { buildFindManyArgs } from '../find/buildFindManyArgs.js'\nimport { transform } from '../transform/read/index.js'\nimport { transformForWrite } from '../transform/write/index.js'\nimport { deleteExistingArrayRows } from './deleteExistingArrayRows.js'\nimport { deleteExistingRowsByPath } from './deleteExistingRowsByPath.js'\nimport { insertArrays } from './insertArrays.js'\n\nexport const upsertRow = async <T extends Record<string, unknown> | TypeWithID>({\n id,\n adapter,\n data,\n db,\n fields,\n ignoreResult,\n // TODO:\n // When we support joins for write operations (create/update) - pass collectionSlug to the buildFindManyArgs\n // Make a new argument in upsertRow.ts and pass the slug from every operation.\n joinQuery: _joinQuery,\n operation,\n path = '',\n req,\n select,\n tableName,\n upsertTarget,\n where,\n}: Args): Promise<T> => {\n // Split out the incoming data into the corresponding:\n // base row, locales, relationships, blocks, and arrays\n const rowToInsert = transformForWrite({\n adapter,\n data,\n fields,\n path,\n tableName,\n })\n\n // First, we insert the main row\n let insertedRow: Record<string, unknown>\n\n try {\n if (operation === 'update') {\n const target = upsertTarget || adapter.tables[tableName].id\n\n if (id) {\n rowToInsert.row.id = id\n ;[insertedRow] = await adapter.insert({\n db,\n onConflictDoUpdate: { set: rowToInsert.row, target },\n tableName,\n values: rowToInsert.row,\n })\n } else {\n ;[insertedRow] = await adapter.insert({\n db,\n onConflictDoUpdate: { set: rowToInsert.row, target, where },\n tableName,\n values: rowToInsert.row,\n })\n }\n } else {\n ;[insertedRow] = await adapter.insert({\n db,\n tableName,\n values: rowToInsert.row,\n })\n }\n\n const localesToInsert: Record<string, unknown>[] = []\n const relationsToInsert: Record<string, unknown>[] = []\n const textsToInsert: Record<string, unknown>[] = []\n const numbersToInsert: Record<string, unknown>[] = []\n const blocksToInsert: { [blockType: string]: BlockRowToInsert[] } = {}\n const selectsToInsert: { [selectTableName: string]: Record<string, unknown>[] } = {}\n\n // If there are locale rows with data, add the parent and locale to each\n if (Object.keys(rowToInsert.locales).length > 0) {\n Object.entries(rowToInsert.locales).forEach(([locale, localeRow]) => {\n localeRow._parentID = insertedRow.id\n localeRow._locale = locale\n localesToInsert.push(localeRow)\n })\n }\n\n // If there are relationships, add parent to each\n if (rowToInsert.relationships.length > 0) {\n rowToInsert.relationships.forEach((relation) => {\n relation.parent = insertedRow.id\n relationsToInsert.push(relation)\n })\n }\n\n // If there are texts, add parent to each\n if (rowToInsert.texts.length > 0) {\n rowToInsert.texts.forEach((textRow) => {\n textRow.parent = insertedRow.id\n textsToInsert.push(textRow)\n })\n }\n\n // If there are numbers, add parent to each\n if (rowToInsert.numbers.length > 0) {\n rowToInsert.numbers.forEach((numberRow) => {\n numberRow.parent = insertedRow.id\n numbersToInsert.push(numberRow)\n })\n }\n\n // If there are selects, add parent to each, and then\n // store by table name and rows\n if (Object.keys(rowToInsert.selects).length > 0) {\n Object.entries(rowToInsert.selects).forEach(([selectTableName, selectRows]) => {\n selectsToInsert[selectTableName] = []\n\n selectRows.forEach((row) => {\n if (typeof row.parent === 'undefined') {\n row.parent = insertedRow.id\n }\n\n selectsToInsert[selectTableName].push(row)\n })\n })\n }\n\n // If there are blocks, add parent to each, and then\n // store by table name and rows\n Object.keys(rowToInsert.blocks).forEach((blockName) => {\n rowToInsert.blocks[blockName].forEach((blockRow) => {\n blockRow.row._parentID = insertedRow.id\n if (!blocksToInsert[blockName]) {\n blocksToInsert[blockName] = []\n }\n if (blockRow.row.uuid) {\n delete blockRow.row.uuid\n }\n blocksToInsert[blockName].push(blockRow)\n })\n })\n\n // //////////////////////////////////\n // INSERT LOCALES\n // //////////////////////////////////\n\n if (localesToInsert.length > 0) {\n const localeTableName = `${tableName}${adapter.localesSuffix}`\n const localeTable = adapter.tables[`${tableName}${adapter.localesSuffix}`]\n\n if (operation === 'update') {\n await adapter.deleteWhere({\n db,\n tableName: localeTableName,\n where: eq(localeTable._parentID, insertedRow.id),\n })\n }\n\n await adapter.insert({\n db,\n tableName: localeTableName,\n values: localesToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT RELATIONSHIPS\n // //////////////////////////////////\n\n const relationshipsTableName = `${tableName}${adapter.relationshipsSuffix}`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: [...relationsToInsert, ...rowToInsert.relationshipsToDelete],\n tableName: relationshipsTableName,\n })\n }\n\n if (relationsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: relationshipsTableName,\n values: relationsToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT hasMany TEXTS\n // //////////////////////////////////\n\n const textsTableName = `${tableName}_texts`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: textsToInsert,\n tableName: textsTableName,\n })\n }\n\n if (textsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: textsTableName,\n values: textsToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT hasMany NUMBERS\n // //////////////////////////////////\n\n const numbersTableName = `${tableName}_numbers`\n\n if (operation === 'update') {\n await deleteExistingRowsByPath({\n adapter,\n db,\n localeColumnName: 'locale',\n parentColumnName: 'parent',\n parentID: insertedRow.id,\n pathColumnName: 'path',\n rows: numbersToInsert,\n tableName: numbersTableName,\n })\n }\n\n if (numbersToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: numbersTableName,\n values: numbersToInsert,\n })\n }\n\n // //////////////////////////////////\n // INSERT BLOCKS\n // //////////////////////////////////\n\n const insertedBlockRows: Record<string, Record<string, unknown>[]> = {}\n\n if (operation === 'update') {\n for (const blockName of rowToInsert.blocksToDelete) {\n const blockTableName = adapter.tableNameMap.get(`${tableName}_blocks_${blockName}`)\n const blockTable = adapter.tables[blockTableName]\n await adapter.deleteWhere({\n db,\n tableName: blockTableName,\n where: eq(blockTable._parentID, insertedRow.id),\n })\n }\n }\n\n // When versions are enabled, this is used to track mapping between blocks/arrays ObjectID to their numeric generated representation, then we use it for nested to arrays/blocks select hasMany in versions.\n const arraysBlocksUUIDMap: Record<string, number | string> = {}\n\n for (const [blockName, blockRows] of Object.entries(blocksToInsert)) {\n const blockTableName = adapter.tableNameMap.get(`${tableName}_blocks_${blockName}`)\n insertedBlockRows[blockName] = await adapter.insert({\n db,\n tableName: blockTableName,\n values: blockRows.map(({ row }) => row),\n })\n\n insertedBlockRows[blockName].forEach((row, i) => {\n blockRows[i].row = row\n if (\n typeof row._uuid === 'string' &&\n (typeof row.id === 'string' || typeof row.id === 'number')\n ) {\n arraysBlocksUUIDMap[row._uuid] = row.id\n }\n })\n\n const blockLocaleIndexMap: number[] = []\n\n const blockLocaleRowsToInsert = blockRows.reduce((acc, blockRow, i) => {\n if (Object.entries(blockRow.locales).length > 0) {\n Object.entries(blockRow.locales).forEach(([blockLocale, blockLocaleData]) => {\n if (Object.keys(blockLocaleData).length > 0) {\n blockLocaleData._parentID = blockRow.row.id\n blockLocaleData._locale = blockLocale\n acc.push(blockLocaleData)\n blockLocaleIndexMap.push(i)\n }\n })\n }\n\n return acc\n }, [])\n\n if (blockLocaleRowsToInsert.length > 0) {\n await adapter.insert({\n db,\n tableName: `${blockTableName}${adapter.localesSuffix}`,\n values: blockLocaleRowsToInsert,\n })\n }\n\n await insertArrays({\n adapter,\n arrays: blockRows.map(({ arrays }) => arrays),\n db,\n parentRows: insertedBlockRows[blockName],\n uuidMap: arraysBlocksUUIDMap,\n })\n }\n\n // //////////////////////////////////\n // INSERT ARRAYS RECURSIVELY\n // //////////////////////////////////\n\n if (operation === 'update') {\n for (const arrayTableName of Object.keys(rowToInsert.arrays)) {\n await deleteExistingArrayRows({\n adapter,\n db,\n parentID: insertedRow.id,\n tableName: arrayTableName,\n })\n }\n }\n\n await insertArrays({\n adapter,\n arrays: [rowToInsert.arrays],\n db,\n parentRows: [insertedRow],\n uuidMap: arraysBlocksUUIDMap,\n })\n\n // //////////////////////////////////\n // INSERT hasMany SELECTS\n // //////////////////////////////////\n\n for (const [selectTableName, tableRows] of Object.entries(selectsToInsert)) {\n const selectTable = adapter.tables[selectTableName]\n if (operation === 'update') {\n await adapter.deleteWhere({\n db,\n tableName: selectTableName,\n where: eq(selectTable.parent, insertedRow.id),\n })\n }\n\n if (Object.keys(arraysBlocksUUIDMap).length > 0) {\n tableRows.forEach((row: any) => {\n if (row.parent in arraysBlocksUUIDMap) {\n row.parent = arraysBlocksUUIDMap[row.parent]\n }\n })\n }\n\n if (tableRows.length) {\n await adapter.insert({\n db,\n tableName: selectTableName,\n values: tableRows,\n })\n }\n }\n\n // //////////////////////////////////\n // Error Handling\n // //////////////////////////////////\n } catch (error) {\n if (error.code === '23505') {\n let fieldName: null | string = null\n // We need to try and find the right constraint for the field but if we can't we fallback to a generic message\n if (adapter.fieldConstraints?.[tableName]) {\n if (adapter.fieldConstraints[tableName]?.[error.constraint]) {\n fieldName = adapter.fieldConstraints[tableName]?.[error.constraint]\n } else {\n const replacement = `${tableName}_`\n\n if (error.constraint.includes(replacement)) {\n const replacedConstraint = error.constraint.replace(replacement, '')\n\n if (replacedConstraint && adapter.fieldConstraints[tableName]?.[replacedConstraint]) {\n fieldName = adapter.fieldConstraints[tableName][replacedConstraint]\n }\n }\n }\n }\n\n if (!fieldName) {\n // Last case scenario we extract the key and value from the detail on the error\n const detail = error.detail\n const regex = /Key \\(([^)]+)\\)=\\(([^)]+)\\)/\n const match = detail.match(regex)\n\n if (match) {\n const key = match[1]\n\n fieldName = key\n }\n }\n\n throw new ValidationError(\n {\n id,\n errors: [\n {\n message: req?.t ? req.t('error:valueMustBeUnique') : 'Value must be unique',\n path: fieldName,\n },\n ],\n },\n req?.t,\n )\n } else {\n throw error\n }\n }\n\n if (ignoreResult === 'idOnly') {\n return { id: insertedRow.id } as T\n }\n\n if (ignoreResult) {\n return data as T\n }\n\n // //////////////////////////////////\n // RETRIEVE NEWLY UPDATED ROW\n // //////////////////////////////////\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n joinQuery: false,\n select,\n tableName,\n })\n\n findManyArgs.where = eq(adapter.tables[tableName].id, insertedRow.id)\n\n const doc = await db.query[tableName].findFirst(findManyArgs)\n\n // //////////////////////////////////\n // TRANSFORM DATA\n // //////////////////////////////////\n\n const result = transform<T>({\n adapter,\n config: adapter.payload.config,\n data: doc,\n fields,\n joinQuery: false,\n })\n\n return result\n}\n"],"names":["eq","ValidationError","buildFindManyArgs","transform","transformForWrite","deleteExistingArrayRows","deleteExistingRowsByPath","insertArrays","upsertRow","id","adapter","data","db","fields","ignoreResult","joinQuery","_joinQuery","operation","path","req","select","tableName","upsertTarget","where","rowToInsert","insertedRow","target","tables","row","insert","onConflictDoUpdate","set","values","localesToInsert","relationsToInsert","textsToInsert","numbersToInsert","blocksToInsert","selectsToInsert","Object","keys","locales","length","entries","forEach","locale","localeRow","_parentID","_locale","push","relationships","relation","parent","texts","textRow","numbers","numberRow","selects","selectTableName","selectRows","blocks","blockName","blockRow","uuid","localeTableName","localesSuffix","localeTable","deleteWhere","relationshipsTableName","relationshipsSuffix","localeColumnName","parentColumnName","parentID","pathColumnName","rows","relationshipsToDelete","textsTableName","numbersTableName","insertedBlockRows","blocksToDelete","blockTableName","tableNameMap","get","blockTable","arraysBlocksUUIDMap","blockRows","map","i","_uuid","blockLocaleIndexMap","blockLocaleRowsToInsert","reduce","acc","blockLocale","blockLocaleData","arrays","parentRows","uuidMap","arrayTableName","tableRows","selectTable","error","code","fieldName","fieldConstraints","constraint","replacement","includes","replacedConstraint","replace","detail","regex","match","key","errors","message","t","findManyArgs","depth","doc","query","findFirst","result","config","payload"],"mappings":"AAEA,SAASA,EAAE,QAAQ,cAAa;AAChC,SAASC,eAAe,QAAQ,UAAS;AAKzC,SAASC,iBAAiB,QAAQ,+BAA8B;AAChE,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,YAAY,QAAQ,oBAAmB;AAEhD,OAAO,MAAMC,YAAY,OAAuD,EAC9EC,EAAE,EACFC,OAAO,EACPC,IAAI,EACJC,EAAE,EACFC,MAAM,EACNC,YAAY,EACZ,QAAQ;AACR,4GAA4G;AAC5G,8EAA8E;AAC9EC,WAAWC,UAAU,EACrBC,SAAS,EACTC,OAAO,EAAE,EACTC,GAAG,EACHC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,KAAK,EACA;IACL,sDAAsD;IACtD,uDAAuD;IACvD,MAAMC,cAAcpB,kBAAkB;QACpCM;QACAC;QACAE;QACAK;QACAG;IACF;IAEA,gCAAgC;IAChC,IAAII;IAEJ,IAAI;QACF,IAAIR,cAAc,UAAU;YAC1B,MAAMS,SAASJ,gBAAgBZ,QAAQiB,MAAM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;IAC9B;IAEA,IAAIK,cAAc;QAChB,OAAOH;IACT;IAEA,qCAAqC;IACrC,6BAA6B;IAC7B,qCAAqC;IAErC,MAAM0G,eAAenH,kBAAkB;QACrCQ;QACA4G,OAAO;QACPzG;QACAE,WAAW;QACXK;QACAC;IACF;IAEAgG,aAAa9F,KAAK,GAAGvB,GAAGU,QAAQiB,MAAM,CAACN,UAAU,CAACZ,EAAE,EAAEgB,YAAYhB,EAAE;IAEpE,MAAM8G,MAAM,MAAM3G,GAAG4G,KAAK,CAACnG,UAAU,CAACoG,SAAS,CAACJ;IAEhD,qCAAqC;IACrC,iBAAiB;IACjB,qCAAqC;IAErC,MAAMK,SAASvH,UAAa;QAC1BO;QACAiH,QAAQjH,QAAQkH,OAAO,CAACD,MAAM;QAC9BhH,MAAM4G;QACN1G;QACAE,WAAW;IACb;IAEA,OAAO2G;AACT,EAAC"}
|
|
@@ -10,7 +10,7 @@ type BaseArgs = {
|
|
|
10
10
|
* When true, skips reading the data back from the database and returns the input data
|
|
11
11
|
* @default false
|
|
12
12
|
*/
|
|
13
|
-
ignoreResult?: boolean;
|
|
13
|
+
ignoreResult?: boolean | 'idOnly';
|
|
14
14
|
joinQuery?: JoinQuery;
|
|
15
15
|
path?: string;
|
|
16
16
|
req?: Partial<PayloadRequest>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/upsertRow/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAEpF,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEpF,KAAK,QAAQ,GAAG;IACd,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OA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GAAG,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,SAAS,CAAA;IACrB,SAAS,EAAE,QAAQ,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,YAAY,CAAC,EAAE,aAAa,CAAA;IAC5B,KAAK,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACrB,GAAG,QAAQ,CAAA;AAEZ,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/upsertRow/types.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { FlattenedField, JoinQuery, PayloadRequest, SelectType } from 'payload'\n\nimport type { DrizzleAdapter, DrizzleTransaction, GenericColumn } from '../types.js'\n\ntype BaseArgs = {\n adapter: DrizzleAdapter\n data: Record<string, unknown>\n db: DrizzleAdapter['drizzle'] | DrizzleTransaction\n fields: FlattenedField[]\n /**\n * When true, skips reading the data back from the database and returns the input data\n * @default false\n */\n ignoreResult?: boolean\n joinQuery?: JoinQuery\n path?: string\n req?: Partial<PayloadRequest>\n tableName: string\n}\n\ntype CreateArgs = {\n id?: never\n joinQuery?: never\n operation: 'create'\n select?: SelectType\n upsertTarget?: never\n where?: never\n} & BaseArgs\n\ntype UpdateArgs = {\n id?: number | string\n joinQuery?: JoinQuery\n operation: 'update'\n select?: SelectType\n upsertTarget?: GenericColumn\n where?: SQL<unknown>\n} & BaseArgs\n\nexport type Args = CreateArgs | UpdateArgs\n"],"names":[],"mappings":"AAuCA,WAA0C"}
|
|
1
|
+
{"version":3,"sources":["../../src/upsertRow/types.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { FlattenedField, JoinQuery, PayloadRequest, SelectType } from 'payload'\n\nimport type { DrizzleAdapter, DrizzleTransaction, GenericColumn } from '../types.js'\n\ntype BaseArgs = {\n adapter: DrizzleAdapter\n data: Record<string, unknown>\n db: DrizzleAdapter['drizzle'] | DrizzleTransaction\n fields: FlattenedField[]\n /**\n * When true, skips reading the data back from the database and returns the input data\n * @default false\n */\n ignoreResult?: boolean | 'idOnly'\n joinQuery?: JoinQuery\n path?: string\n req?: Partial<PayloadRequest>\n tableName: string\n}\n\ntype CreateArgs = {\n id?: never\n joinQuery?: never\n operation: 'create'\n select?: SelectType\n upsertTarget?: never\n where?: never\n} & BaseArgs\n\ntype UpdateArgs = {\n id?: number | string\n joinQuery?: JoinQuery\n operation: 'update'\n select?: SelectType\n upsertTarget?: GenericColumn\n where?: SQL<unknown>\n} & BaseArgs\n\nexport type Args = CreateArgs | UpdateArgs\n"],"names":[],"mappings":"AAuCA,WAA0C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.26.0",
|
|
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.9.0",
|
|
56
|
-
"payload": "3.
|
|
56
|
+
"payload": "3.26.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"payload": "3.
|
|
59
|
+
"payload": "3.26.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "pnpm build:swc && pnpm build:types",
|