@payloadcms/db-postgres 3.0.0-alpha.53 → 3.0.0-alpha.55

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. package/dist/create.d.ts.map +1 -1
  2. package/dist/create.js +5 -2
  3. package/dist/create.js.map +1 -1
  4. package/dist/createGlobal.d.ts.map +1 -1
  5. package/dist/createGlobal.js +5 -2
  6. package/dist/createGlobal.js.map +1 -1
  7. package/dist/createGlobalVersion.d.ts.map +1 -1
  8. package/dist/createGlobalVersion.js +6 -3
  9. package/dist/createGlobalVersion.js.map +1 -1
  10. package/dist/createVersion.d.ts.map +1 -1
  11. package/dist/createVersion.js +12 -4
  12. package/dist/createVersion.js.map +1 -1
  13. package/dist/deleteMany.js +5 -2
  14. package/dist/deleteMany.js.map +1 -1
  15. package/dist/deleteOne.d.ts.map +1 -1
  16. package/dist/deleteOne.js +5 -2
  17. package/dist/deleteOne.js.map +1 -1
  18. package/dist/deleteVersions.d.ts.map +1 -1
  19. package/dist/deleteVersions.js +6 -2
  20. package/dist/deleteVersions.js.map +1 -1
  21. package/dist/find/traverseFields.d.ts.map +1 -1
  22. package/dist/find/traverseFields.js +24 -5
  23. package/dist/find/traverseFields.js.map +1 -1
  24. package/dist/find.d.ts.map +1 -1
  25. package/dist/find.js +9 -5
  26. package/dist/find.js.map +1 -1
  27. package/dist/findGlobal.d.ts.map +1 -1
  28. package/dist/findGlobal.js +5 -2
  29. package/dist/findGlobal.js.map +1 -1
  30. package/dist/findGlobalVersions.d.ts.map +1 -1
  31. package/dist/findGlobalVersions.js +6 -2
  32. package/dist/findGlobalVersions.js.map +1 -1
  33. package/dist/findOne.d.ts +1 -1
  34. package/dist/findOne.d.ts.map +1 -1
  35. package/dist/findOne.js +8 -4
  36. package/dist/findOne.js.map +1 -1
  37. package/dist/findVersions.d.ts.map +1 -1
  38. package/dist/findVersions.js +6 -2
  39. package/dist/findVersions.js.map +1 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +4 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/init.d.ts.map +1 -1
  45. package/dist/init.js +27 -9
  46. package/dist/init.js.map +1 -1
  47. package/dist/migrate.js.map +1 -1
  48. package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
  49. package/dist/queries/getTableColumnFromPath.js +57 -13
  50. package/dist/queries/getTableColumnFromPath.js.map +1 -1
  51. package/dist/queryDrafts.d.ts.map +1 -1
  52. package/dist/queryDrafts.js +6 -2
  53. package/dist/queryDrafts.js.map +1 -1
  54. package/dist/schema/build.d.ts +2 -1
  55. package/dist/schema/build.d.ts.map +1 -1
  56. package/dist/schema/build.js +18 -8
  57. package/dist/schema/build.js.map +1 -1
  58. package/dist/schema/getTableName.d.ts +32 -0
  59. package/dist/schema/getTableName.d.ts.map +1 -0
  60. package/dist/schema/getTableName.js +31 -0
  61. package/dist/schema/getTableName.js.map +1 -0
  62. package/dist/schema/traverseFields.d.ts +2 -1
  63. package/dist/schema/traverseFields.d.ts.map +1 -1
  64. package/dist/schema/traverseFields.js +52 -15
  65. package/dist/schema/traverseFields.js.map +1 -1
  66. package/dist/types.d.ts +13 -0
  67. package/dist/types.d.ts.map +1 -1
  68. package/dist/types.js.map +1 -1
  69. package/dist/update.d.ts.map +1 -1
  70. package/dist/update.js +6 -3
  71. package/dist/update.js.map +1 -1
  72. package/dist/updateGlobal.d.ts.map +1 -1
  73. package/dist/updateGlobal.js +5 -2
  74. package/dist/updateGlobal.js.map +1 -1
  75. package/dist/updateGlobalVersion.d.ts.map +1 -1
  76. package/dist/updateGlobalVersion.js +6 -2
  77. package/dist/updateGlobalVersion.js.map +1 -1
  78. package/dist/updateVersion.d.ts.map +1 -1
  79. package/dist/updateVersion.js +6 -2
  80. package/dist/updateVersion.js.map +1 -1
  81. package/package.json +3 -3
  82. package/src/index.ts +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAQ9C,eAAO,MAAM,MAAM,EAAE,MAkBpB,CAAA"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAO9C,eAAO,MAAM,MAAM,EAAE,MAqBpB,CAAA"}
package/dist/create.js CHANGED
@@ -1,4 +1,4 @@
1
- import toSnakeCase from 'to-snake-case';
1
+ import { getTableName } from './schema/getTableName.js';
2
2
  import { upsertRow } from './upsertRow/index.js';
3
3
  export const create = async function create({ collection: collectionSlug, data, req }) {
4
4
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
@@ -10,7 +10,10 @@ export const create = async function create({ collection: collectionSlug, data,
10
10
  fields: collection.fields,
11
11
  operation: 'create',
12
12
  req,
13
- tableName: toSnakeCase(collectionSlug)
13
+ tableName: getTableName({
14
+ adapter: this,
15
+ config: collection
16
+ })
14
17
  });
15
18
  return result;
16
19
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload/database'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const create: Create = async function create(\n this: PostgresAdapter,\n { collection: collectionSlug, data, req },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'create',\n req,\n tableName: toSnakeCase(collectionSlug),\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","create","collection","collectionSlug","data","req","db","sessions","transactionID","drizzle","payload","collections","config","result","adapter","fields","operation","tableName"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzC,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMP,aAAa,IAAI,CAACQ,OAAO,CAACC,WAAW,CAACR,eAAe,CAACS,MAAM;IAElE,MAAMC,SAAS,MAAMb,UAAU;QAC7Bc,SAAS,IAAI;QACbV;QACAE;QACAS,QAAQb,WAAWa,MAAM;QACzBC,WAAW;QACXX;QACAY,WAAWlB,YAAYI;IACzB;IAEA,OAAOU;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/create.ts"],"sourcesContent":["import type { Create } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { getTableName } from './schema/getTableName.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport const create: Create = async function create(\n this: PostgresAdapter,\n { collection: collectionSlug, data, req },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n\n const result = await upsertRow({\n adapter: this,\n data,\n db,\n fields: collection.fields,\n operation: 'create',\n req,\n tableName: getTableName({\n adapter: this,\n config: collection,\n }),\n })\n\n return result\n}\n"],"names":["getTableName","upsertRow","create","collection","collectionSlug","data","req","db","sessions","transactionID","drizzle","payload","collections","config","result","adapter","fields","operation","tableName"],"mappings":"AAIA,SAASA,YAAY,QAAQ,2BAA0B;AACvD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,MAAMC,SAAiB,eAAeA,OAE3C,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,GAAG,EAAE;IAEzC,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMP,aAAa,IAAI,CAACQ,OAAO,CAACC,WAAW,CAACR,eAAe,CAACS,MAAM;IAElE,MAAMC,SAAS,MAAMb,UAAU;QAC7Bc,SAAS,IAAI;QACbV;QACAE;QACAS,QAAQb,WAAWa,MAAM;QACzBC,WAAW;QACXX;QACAY,WAAWlB,aAAa;YACtBe,SAAS,IAAI;YACbF,QAAQV;QACV;IACF;IAEA,OAAOW;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAA;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,UAAU,EACrD,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAA0B,EAAE,EAAE,gBAAgB,GAC3D,OAAO,CAAC,CAAC,CAAC,CAeZ"}
1
+ {"version":3,"file":"createGlobal.d.ts","sourceRoot":"","sources":["../src/createGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAA;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKjD,wBAAsB,YAAY,CAAC,CAAC,SAAS,UAAU,EACrD,IAAI,EAAE,eAAe,EACrB,EAAE,IAAI,EAAE,IAAI,EAAE,GAA0B,EAAE,EAAE,gBAAgB,GAC3D,OAAO,CAAC,CAAC,CAAC,CAkBZ"}
@@ -1,4 +1,4 @@
1
- import toSnakeCase from 'to-snake-case';
1
+ import { getTableName } from './schema/getTableName.js';
2
2
  import { upsertRow } from './upsertRow/index.js';
3
3
  export async function createGlobal({ slug, data, req = {} }) {
4
4
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
@@ -10,7 +10,10 @@ export async function createGlobal({ slug, data, req = {} }) {
10
10
  fields: globalConfig.fields,
11
11
  operation: 'create',
12
12
  req,
13
- tableName: toSnakeCase(slug)
13
+ tableName: getTableName({
14
+ adapter: this,
15
+ config: globalConfig
16
+ })
14
17
  });
15
18
  return result;
16
19
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { slug, data, req = {} as PayloadRequest }: CreateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const result = await upsertRow<T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n operation: 'create',\n req,\n tableName: toSnakeCase(slug),\n })\n\n return result\n}\n"],"names":["toSnakeCase","upsertRow","createGlobal","slug","data","req","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","result","adapter","fields","operation","tableName"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAoB;IAE5D,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKA;IAElF,MAAMY,SAAS,MAAMd,UAAa;QAChCe,SAAS,IAAI;QACbZ;QACAE;QACAW,QAAQP,aAAaO,MAAM;QAC3BC,WAAW;QACXb;QACAc,WAAWnB,YAAYG;IACzB;IAEA,OAAOY;AACT"}
1
+ {"version":3,"sources":["../src/createGlobal.ts"],"sourcesContent":["import type { CreateGlobalArgs } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { getTableName } from './schema/getTableName.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobal<T extends TypeWithID>(\n this: PostgresAdapter,\n { slug, data, req = {} as PayloadRequest }: CreateGlobalArgs,\n): Promise<T> {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n\n const result = await upsertRow<T>({\n adapter: this,\n data,\n db,\n fields: globalConfig.fields,\n operation: 'create',\n req,\n tableName: getTableName({\n adapter: this,\n config: globalConfig,\n }),\n })\n\n return result\n}\n"],"names":["getTableName","upsertRow","createGlobal","slug","data","req","db","sessions","transactionID","drizzle","globalConfig","payload","globals","config","find","result","adapter","fields","operation","tableName"],"mappings":"AAKA,SAASA,YAAY,QAAQ,2BAA0B;AACvD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,aAEpB,EAAEC,IAAI,EAAEC,IAAI,EAAEC,MAAM,CAAC,CAAmB,EAAoB;IAE5D,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACF,IAAIG,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOV,IAAI,KAAKA;IAElF,MAAMY,SAAS,MAAMd,UAAa;QAChCe,SAAS,IAAI;QACbZ;QACAE;QACAW,QAAQP,aAAaO,MAAM;QAC3BC,WAAW;QACXb;QACAc,WAAWnB,aAAa;YACtBgB,SAAS,IAAI;YACbH,QAAQH;QACV;IACF;IAEA,OAAOK;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/D,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAI/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EAAE,QAAQ,EAAE,UAAU,EAAE,GAA0B,EAAE,WAAW,EAAE,EAAE,uBAAuB,+BAgC3F"}
1
+ {"version":3,"file":"createGlobalVersion.d.ts","sourceRoot":"","sources":["../src/createGlobalVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAA;AAG/D,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKjD,wBAAsB,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAC5D,IAAI,EAAE,eAAe,EACrB,EAAE,QAAQ,EAAE,UAAU,EAAE,GAA0B,EAAE,WAAW,EAAE,EAAE,uBAAuB,+BAmC3F"}
@@ -1,12 +1,15 @@
1
1
  import { sql } from 'drizzle-orm';
2
2
  import { buildVersionGlobalFields } from 'payload/versions';
3
- import toSnakeCase from 'to-snake-case';
3
+ import { getTableName } from './schema/getTableName.js';
4
4
  import { upsertRow } from './upsertRow/index.js';
5
5
  export async function createGlobalVersion({ autosave, globalSlug, req = {}, versionData }) {
6
6
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
7
7
  const global = this.payload.globals.config.find(({ slug })=>slug === globalSlug);
8
- const globalTableName = toSnakeCase(globalSlug);
9
- const tableName = `_${globalTableName}_v`;
8
+ const tableName = getTableName({
9
+ adapter: this,
10
+ config: global,
11
+ versions: true
12
+ });
10
13
  const result = await upsertRow({
11
14
  adapter: this,
12
15
  data: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { TypeWithVersion } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { type CreateGlobalVersionArgs } from 'payload/database'\nimport { buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n { autosave, globalSlug, req = {} as PayloadRequest, versionData }: CreateGlobalVersionArgs,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n const globalTableName = toSnakeCase(globalSlug)\n const tableName = `_${globalTableName}_v`\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(global),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (global.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","toSnakeCase","upsertRow","createGlobalVersion","autosave","globalSlug","req","versionData","db","sessions","transactionID","drizzle","global","payload","globals","config","find","slug","globalTableName","tableName","result","adapter","data","latest","version","fields","operation","table","tables","versions","drafts","execute","id"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAEjC,SAASC,wBAAwB,QAAQ,mBAAkB;AAC3D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,WAAW,EAA2B;IAE1F,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASZ;IACvE,MAAMa,kBAAkBjB,YAAYI;IACpC,MAAMc,YAAY,CAAC,CAAC,EAAED,gBAAgB,EAAE,CAAC;IAEzC,MAAME,SAAS,MAAMlB,UAA8B;QACjDmB,SAAS,IAAI;QACbC,MAAM;YACJlB;YACAmB,QAAQ;YACRC,SAASjB;QACX;QACAC;QACAiB,QAAQzB,yBAAyBY;QACjCc,WAAW;QACXpB;QACAa;IACF;IAEA,MAAMQ,QAAQ,IAAI,CAACC,MAAM,CAACT,UAAU;IAEpC,IAAIP,OAAOiB,QAAQ,CAACC,MAAM,EAAE;QAC1B,MAAMtB,GAAGuB,OAAO,CAAChC,GAAG,CAAC;aACZ,EAAE4B,MAAM;;YAET,EAAEA,MAAMK,EAAE,CAAC,IAAI,EAAEZ,OAAOY,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOZ;AACT"}
1
+ {"version":3,"sources":["../src/createGlobalVersion.ts"],"sourcesContent":["import type { TypeWithVersion } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { type CreateGlobalVersionArgs } from 'payload/database'\nimport { buildVersionGlobalFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { getTableName } from './schema/getTableName.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createGlobalVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n { autosave, globalSlug, req = {} as PayloadRequest, versionData }: CreateGlobalVersionArgs,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const global = this.payload.globals.config.find(({ slug }) => slug === globalSlug)\n const tableName = getTableName({\n adapter: this,\n config: global,\n versions: true,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n version: versionData,\n },\n db,\n fields: buildVersionGlobalFields(global),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n if (global.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n WHERE ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionGlobalFields","getTableName","upsertRow","createGlobalVersion","autosave","globalSlug","req","versionData","db","sessions","transactionID","drizzle","global","payload","globals","config","find","slug","tableName","adapter","versions","result","data","latest","version","fields","operation","table","tables","drafts","execute","id"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AAEjC,SAASC,wBAAwB,QAAQ,mBAAkB;AAI3D,SAASC,YAAY,QAAQ,2BAA0B;AACvD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,oBAEpB,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,WAAW,EAA2B;IAE1F,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,SAAS,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASZ;IACvE,MAAMa,YAAYjB,aAAa;QAC7BkB,SAAS,IAAI;QACbJ,QAAQH;QACRQ,UAAU;IACZ;IAEA,MAAMC,SAAS,MAAMnB,UAA8B;QACjDiB,SAAS,IAAI;QACbG,MAAM;YACJlB;YACAmB,QAAQ;YACRC,SAASjB;QACX;QACAC;QACAiB,QAAQzB,yBAAyBY;QACjCc,WAAW;QACXpB;QACAY;IACF;IAEA,MAAMS,QAAQ,IAAI,CAACC,MAAM,CAACV,UAAU;IAEpC,IAAIN,OAAOQ,QAAQ,CAACS,MAAM,EAAE;QAC1B,MAAMrB,GAAGsB,OAAO,CAAC/B,GAAG,CAAC;aACZ,EAAE4B,MAAM;;YAET,EAAEA,MAAMI,EAAE,CAAC,IAAI,EAAEV,OAAOU,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOV;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAA;AAM/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,eAAe,EACrB,EACE,QAAQ,EACR,cAAc,EACd,MAAM,EACN,GAA0B,EAC1B,WAAW,GACZ,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAsCxB"}
1
+ {"version":3,"file":"createVersion.d.ts","sourceRoot":"","sources":["../src/createVersion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAC1E,OAAO,KAAK,EAAkB,UAAU,EAAE,MAAM,eAAe,CAAA;AAK/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKjD,wBAAsB,aAAa,CAAC,CAAC,SAAS,UAAU,EACtD,IAAI,EAAE,eAAe,EACrB,EACE,QAAQ,EACR,cAAc,EACd,MAAM,EACN,GAA0B,EAC1B,WAAW,GACZ,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAiDxB"}
@@ -1,12 +1,15 @@
1
1
  import { sql } from 'drizzle-orm';
2
2
  import { buildVersionCollectionFields } from 'payload/versions';
3
- import toSnakeCase from 'to-snake-case';
3
+ import { getTableName } from './schema/getTableName.js';
4
4
  import { upsertRow } from './upsertRow/index.js';
5
5
  export async function createVersion({ autosave, collectionSlug, parent, req = {}, versionData }) {
6
6
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
7
7
  const collection = this.payload.collections[collectionSlug].config;
8
- const collectionTableName = toSnakeCase(collectionSlug);
9
- const tableName = `_${collectionTableName}_v`;
8
+ const tableName = getTableName({
9
+ adapter: this,
10
+ config: collection,
11
+ versions: true
12
+ });
10
13
  const result = await upsertRow({
11
14
  adapter: this,
12
15
  data: {
@@ -22,7 +25,12 @@ export async function createVersion({ autosave, collectionSlug, parent, req = {}
22
25
  tableName
23
26
  });
24
27
  const table = this.tables[tableName];
25
- const relationshipsTable = this.tables[`${tableName}_rels`];
28
+ const relationshipsTable = this.tables[getTableName({
29
+ adapter: this,
30
+ config: collection,
31
+ relationships: true,
32
+ versions: true
33
+ })];
26
34
  if (collection.versions.drafts) {
27
35
  await db.execute(sql`
28
36
  UPDATE ${table}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, TypeWithVersion } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n collectionSlug,\n parent,\n req = {} as PayloadRequest,\n versionData,\n }: CreateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const collectionTableName = toSnakeCase(collectionSlug)\n const tableName = `_${collectionTableName}_v`\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n parent,\n version: versionData,\n },\n db,\n fields: buildVersionCollectionFields(collection),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n const relationshipsTable = this.tables[`${tableName}_rels`]\n\n if (collection.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n FROM ${relationshipsTable}\n WHERE ${table.id} = ${relationshipsTable.parent}\n AND ${relationshipsTable.path} = ${'parent'}\n AND ${relationshipsTable[`${collectionSlug}ID`]} = ${parent}\n AND ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","toSnakeCase","upsertRow","createVersion","autosave","collectionSlug","parent","req","versionData","db","sessions","transactionID","drizzle","collection","payload","collections","config","collectionTableName","tableName","result","adapter","data","latest","version","fields","operation","table","tables","relationshipsTable","versions","drafts","execute","id","path"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,cAEpB,EACEC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACU;IAEvB,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,aAAa,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,eAAe,CAACW,MAAM;IAClE,MAAMC,sBAAsBhB,YAAYI;IACxC,MAAMa,YAAY,CAAC,CAAC,EAAED,oBAAoB,EAAE,CAAC;IAE7C,MAAME,SAAS,MAAMjB,UAA8B;QACjDkB,SAAS,IAAI;QACbC,MAAM;YACJjB;YACAkB,QAAQ;YACRhB;YACAiB,SAASf;QACX;QACAC;QACAe,QAAQxB,6BAA6Ba;QACrCY,WAAW;QACXlB;QACAW;IACF;IAEA,MAAMQ,QAAQ,IAAI,CAACC,MAAM,CAACT,UAAU;IACpC,MAAMU,qBAAqB,IAAI,CAACD,MAAM,CAAC,CAAC,EAAET,UAAU,KAAK,CAAC,CAAC;IAE3D,IAAIL,WAAWgB,QAAQ,CAACC,MAAM,EAAE;QAC9B,MAAMrB,GAAGsB,OAAO,CAAChC,GAAG,CAAC;aACZ,EAAE2B,MAAM;;WAEV,EAAEE,mBAAmB;YACpB,EAAEF,MAAMM,EAAE,CAAC,GAAG,EAAEJ,mBAAmBtB,MAAM,CAAC;YAC1C,EAAEsB,mBAAmBK,IAAI,CAAC,GAAG,EAAE,SAAS;YACxC,EAAEL,kBAAkB,CAAC,CAAC,EAAEvB,eAAe,EAAE,CAAC,CAAC,CAAC,GAAG,EAAEC,OAAO;YACxD,EAAEoB,MAAMM,EAAE,CAAC,IAAI,EAAEb,OAAOa,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOb;AACT"}
1
+ {"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, TypeWithVersion } from 'payload/database'\nimport type { PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { sql } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { getTableName } from './schema/getTableName.js'\nimport { upsertRow } from './upsertRow/index.js'\n\nexport async function createVersion<T extends TypeWithID>(\n this: PostgresAdapter,\n {\n autosave,\n collectionSlug,\n parent,\n req = {} as PayloadRequest,\n versionData,\n }: CreateVersionArgs<T>,\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const tableName = getTableName({\n adapter: this,\n config: collection,\n versions: true,\n })\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n parent,\n version: versionData,\n },\n db,\n fields: buildVersionCollectionFields(collection),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n const relationshipsTable =\n this.tables[\n getTableName({\n adapter: this,\n config: collection,\n relationships: true,\n versions: true,\n })\n ]\n\n if (collection.versions.drafts) {\n await db.execute(sql`\n UPDATE ${table}\n SET latest = false\n FROM ${relationshipsTable}\n WHERE ${table.id} = ${relationshipsTable.parent}\n AND ${relationshipsTable.path} = ${'parent'}\n AND ${relationshipsTable[`${collectionSlug}ID`]} = ${parent}\n AND ${table.id} != ${result.id};\n `)\n }\n\n return result\n}\n"],"names":["sql","buildVersionCollectionFields","getTableName","upsertRow","createVersion","autosave","collectionSlug","parent","req","versionData","db","sessions","transactionID","drizzle","collection","payload","collections","config","tableName","adapter","versions","result","data","latest","version","fields","operation","table","tables","relationshipsTable","relationships","drafts","execute","id","path"],"mappings":"AAGA,SAASA,GAAG,QAAQ,cAAa;AACjC,SAASC,4BAA4B,QAAQ,mBAAkB;AAI/D,SAASC,YAAY,QAAQ,2BAA0B;AACvD,SAASC,SAAS,QAAQ,uBAAsB;AAEhD,OAAO,eAAeC,cAEpB,EACEC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,CAAC,CAAmB,EAC1BC,WAAW,EACU;IAEvB,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,aAAa,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,eAAe,CAACW,MAAM;IAClE,MAAMC,YAAYhB,aAAa;QAC7BiB,SAAS,IAAI;QACbF,QAAQH;QACRM,UAAU;IACZ;IAEA,MAAMC,SAAS,MAAMlB,UAA8B;QACjDgB,SAAS,IAAI;QACbG,MAAM;YACJjB;YACAkB,QAAQ;YACRhB;YACAiB,SAASf;QACX;QACAC;QACAe,QAAQxB,6BAA6Ba;QACrCY,WAAW;QACXlB;QACAU;IACF;IAEA,MAAMS,QAAQ,IAAI,CAACC,MAAM,CAACV,UAAU;IACpC,MAAMW,qBACJ,IAAI,CAACD,MAAM,CACT1B,aAAa;QACXiB,SAAS,IAAI;QACbF,QAAQH;QACRgB,eAAe;QACfV,UAAU;IACZ,GACD;IAEH,IAAIN,WAAWM,QAAQ,CAACW,MAAM,EAAE;QAC9B,MAAMrB,GAAGsB,OAAO,CAAChC,GAAG,CAAC;aACZ,EAAE2B,MAAM;;WAEV,EAAEE,mBAAmB;YACpB,EAAEF,MAAMM,EAAE,CAAC,GAAG,EAAEJ,mBAAmBtB,MAAM,CAAC;YAC1C,EAAEsB,mBAAmBK,IAAI,CAAC,GAAG,EAAE,SAAS;YACxC,EAAEL,kBAAkB,CAAC,CAAC,EAAEvB,eAAe,EAAE,CAAC,CAAC,CAAC,GAAG,EAAEC,OAAO;YACxD,EAAEoB,MAAMM,EAAE,CAAC,IAAI,EAAEZ,OAAOY,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOZ;AACT"}
@@ -1,10 +1,13 @@
1
1
  import { inArray } from 'drizzle-orm';
2
- import toSnakeCase from 'to-snake-case';
3
2
  import { findMany } from './find/findMany.js';
3
+ import { getTableName } from './schema/getTableName.js';
4
4
  export const deleteMany = async function deleteMany({ collection, req = {}, where }) {
5
5
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
6
6
  const collectionConfig = this.payload.collections[collection].config;
7
- const tableName = toSnakeCase(collection);
7
+ const tableName = getTableName({
8
+ adapter: this,
9
+ config: collectionConfig
10
+ });
8
11
  const result = await findMany({
9
12
  adapter: this,
10
13
  fields: collectionConfig.fields,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteMany } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { inArray } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const deleteMany: DeleteMany = async function deleteMany(\n this: PostgresAdapter,\n { collection, req = {} as PayloadRequest, where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig = this.payload.collections[collection].config\n const tableName = toSnakeCase(collection)\n\n const result = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 0,\n locale: req.locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n result.docs.forEach((data) => {\n ids.push(data.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n}\n"],"names":["inArray","toSnakeCase","findMany","deleteMany","collection","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","result","adapter","fields","limit","locale","page","pagination","ids","docs","forEach","data","push","id","length","delete","tables"],"mappings":"AAGA,SAASA,OAAO,QAAQ,cAAa;AACrC,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEjD,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACT,WAAW,CAACU,MAAM;IACpE,MAAMC,YAAYd,YAAYG;IAE9B,MAAMY,SAAS,MAAMd,SAAS;QAC5Be,SAAS,IAAI;QACbC,QAAQP,iBAAiBO,MAAM;QAC/BC,OAAO;QACPC,QAAQf,IAAIe,MAAM;QAClBC,MAAM;QACNC,YAAY;QACZjB;QACAU;QACAT;IACF;IAEA,MAAMiB,MAAM,EAAE;IAEdP,OAAOQ,IAAI,CAACC,OAAO,CAAC,CAACC;QACnBH,IAAII,IAAI,CAACD,KAAKE,EAAE;IAClB;IAEA,IAAIL,IAAIM,MAAM,GAAG,GAAG;QAClB,MAAMtB,GAAGuB,MAAM,CAAC,IAAI,CAACC,MAAM,CAAChB,UAAU,EAAET,KAAK,CAACN,QAAQ,IAAI,CAAC+B,MAAM,CAAChB,UAAU,CAACa,EAAE,EAAEL;IACnF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteMany } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { inArray } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const deleteMany: DeleteMany = async function deleteMany(\n this: PostgresAdapter,\n { collection, req = {} as PayloadRequest, where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig = this.payload.collections[collection].config\n const tableName = getTableName({ adapter: this, config: collectionConfig })\n\n const result = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 0,\n locale: req.locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n result.docs.forEach((data) => {\n ids.push(data.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n}\n"],"names":["inArray","findMany","getTableName","deleteMany","collection","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","adapter","result","fields","limit","locale","page","pagination","ids","docs","forEach","data","push","id","length","delete","tables"],"mappings":"AAGA,SAASA,OAAO,QAAQ,cAAa;AAIrC,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,UAAU,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAE;IAEjD,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAAmB,IAAI,CAACC,OAAO,CAACC,WAAW,CAACT,WAAW,CAACU,MAAM;IACpE,MAAMC,YAAYb,aAAa;QAAEc,SAAS,IAAI;QAAEF,QAAQH;IAAiB;IAEzE,MAAMM,SAAS,MAAMhB,SAAS;QAC5Be,SAAS,IAAI;QACbE,QAAQP,iBAAiBO,MAAM;QAC/BC,OAAO;QACPC,QAAQf,IAAIe,MAAM;QAClBC,MAAM;QACNC,YAAY;QACZjB;QACAU;QACAT;IACF;IAEA,MAAMiB,MAAM,EAAE;IAEdN,OAAOO,IAAI,CAACC,OAAO,CAAC,CAACC;QACnBH,IAAII,IAAI,CAACD,KAAKE,EAAE;IAClB;IAEA,IAAIL,IAAIM,MAAM,GAAG,GAAG;QAClB,MAAMtB,GAAGuB,MAAM,CAAC,IAAI,CAACC,MAAM,CAAChB,UAAU,EAAET,KAAK,CAACN,QAAQ,IAAI,CAAC+B,MAAM,CAAChB,UAAU,CAACa,EAAE,EAAEL;IACnF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAajD,eAAO,MAAM,SAAS,EAAE,SAsDvB,CAAA"}
1
+ {"version":3,"file":"deleteOne.d.ts","sourceRoot":"","sources":["../src/deleteOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAajD,eAAO,MAAM,SAAS,EAAE,SAyDvB,CAAA"}
package/dist/deleteOne.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { eq } from 'drizzle-orm';
2
- import toSnakeCase from 'to-snake-case';
3
2
  import { buildFindManyArgs } from './find/buildFindManyArgs.js';
4
3
  import buildQuery from './queries/buildQuery.js';
5
4
  import { selectDistinct } from './queries/selectDistinct.js';
5
+ import { getTableName } from './schema/getTableName.js';
6
6
  import { transform } from './transform/read/index.js';
7
7
  export const deleteOne = async function deleteOne({ collection: collectionSlug, req = {}, where: whereArg }) {
8
8
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
9
9
  const collection = this.payload.collections[collectionSlug].config;
10
- const tableName = toSnakeCase(collectionSlug);
10
+ const tableName = getTableName({
11
+ adapter: this,
12
+ config: collection
13
+ });
11
14
  let docToDelete;
12
15
  const { joinAliases, joins, selectFields, where } = await buildQuery({
13
16
  adapter: this,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { eq } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } 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'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: PostgresAdapter,\n { collection: collectionSlug, req = {} as PayloadRequest, where: whereArg },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const tableName = toSnakeCase(collectionSlug)\n let docToDelete: Record<string, unknown>\n\n const { joinAliases, joins, selectFields, where } = await buildQuery({\n adapter: this,\n fields: collection.fields,\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 joinAliases,\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.fields,\n tableName,\n })\n\n findManyArgs.where = where\n\n docToDelete = await db.query[tableName].findFirst(findManyArgs)\n }\n\n const result = transform({\n config: this.payload.config,\n data: docToDelete,\n fields: collection.fields,\n })\n\n await db.delete(this.tables[tableName]).where(eq(this.tables[tableName].id, docToDelete.id))\n\n return result\n}\n"],"names":["eq","toSnakeCase","buildFindManyArgs","buildQuery","selectDistinct","transform","deleteOne","collection","collectionSlug","req","where","whereArg","db","sessions","transactionID","drizzle","payload","collections","config","tableName","docToDelete","joinAliases","joins","selectFields","adapter","fields","locale","selectDistinctResult","chainedMethods","args","method","id","query","findFirst","tables","findManyArgs","depth","result","data","delete"],"mappings":"AAGA,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;AAErD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,YAAYC,cAAc,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOC,QAAQ,EAAE;IAE3E,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACJ,IAAIK,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMR,aAAa,IAAI,CAACS,OAAO,CAACC,WAAW,CAACT,eAAe,CAACU,MAAM;IAClE,MAAMC,YAAYlB,YAAYO;IAC9B,IAAIY;IAEJ,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,YAAY,EAAEb,KAAK,EAAE,GAAG,MAAMP,WAAW;QACnEqB,SAAS,IAAI;QACbC,QAAQlB,WAAWkB,MAAM;QACzBC,QAAQjB,IAAIiB,MAAM;QAClBP;QACAT,OAAOC;IACT;IAEA,MAAMgB,uBAAuB,MAAMvB,eAAe;QAChDoB,SAAS,IAAI;QACbI,gBAAgB;YAAC;gBAAEC,MAAM;oBAAC;iBAAE;gBAAEC,QAAQ;YAAQ;SAAE;QAChDlB;QACAS;QACAC;QACAC;QACAJ;QACAT;IACF;IAEA,IAAIiB,sBAAsB,CAAC,EAAE,EAAEI,IAAI;QACjCX,cAAc,MAAMR,GAAGoB,KAAK,CAACb,UAAU,CAACc,SAAS,CAAC;YAChDvB,OAAOV,GAAG,IAAI,CAACkC,MAAM,CAACf,UAAU,CAACY,EAAE,EAAEJ,oBAAoB,CAAC,EAAE,CAACI,EAAE;QACjE;IACF,OAAO;QACL,MAAMI,eAAejC,kBAAkB;YACrCsB,SAAS,IAAI;YACbY,OAAO;YACPX,QAAQlB,WAAWkB,MAAM;YACzBN;QACF;QAEAgB,aAAazB,KAAK,GAAGA;QAErBU,cAAc,MAAMR,GAAGoB,KAAK,CAACb,UAAU,CAACc,SAAS,CAACE;IACpD;IAEA,MAAME,SAAShC,UAAU;QACvBa,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;QAC3BoB,MAAMlB;QACNK,QAAQlB,WAAWkB,MAAM;IAC3B;IAEA,MAAMb,GAAG2B,MAAM,CAAC,IAAI,CAACL,MAAM,CAACf,UAAU,EAAET,KAAK,CAACV,GAAG,IAAI,CAACkC,MAAM,CAACf,UAAU,CAACY,EAAE,EAAEX,YAAYW,EAAE;IAE1F,OAAOM;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne } from 'payload/database'\nimport type { PayloadRequest } from 'payload/types'\n\nimport { eq } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { buildFindManyArgs } from './find/buildFindManyArgs.js'\nimport buildQuery from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { getTableName } from './schema/getTableName.js'\nimport { transform } from './transform/read/index.js'\n\nexport const deleteOne: DeleteOne = async function deleteOne(\n this: PostgresAdapter,\n { collection: collectionSlug, req = {} as PayloadRequest, where: whereArg },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collection = this.payload.collections[collectionSlug].config\n const tableName = getTableName({\n adapter: this,\n config: collection,\n })\n let docToDelete: Record<string, unknown>\n\n const { joinAliases, joins, selectFields, where } = await buildQuery({\n adapter: this,\n fields: collection.fields,\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 joinAliases,\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.fields,\n tableName,\n })\n\n findManyArgs.where = where\n\n docToDelete = await db.query[tableName].findFirst(findManyArgs)\n }\n\n const result = transform({\n config: this.payload.config,\n data: docToDelete,\n fields: collection.fields,\n })\n\n await db.delete(this.tables[tableName]).where(eq(this.tables[tableName].id, docToDelete.id))\n\n return result\n}\n"],"names":["eq","buildFindManyArgs","buildQuery","selectDistinct","getTableName","transform","deleteOne","collection","collectionSlug","req","where","whereArg","db","sessions","transactionID","drizzle","payload","collections","config","tableName","adapter","docToDelete","joinAliases","joins","selectFields","fields","locale","selectDistinctResult","chainedMethods","args","method","id","query","findFirst","tables","findManyArgs","depth","result","data","delete"],"mappings":"AAGA,SAASA,EAAE,QAAQ,cAAa;AAIhC,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,OAAOC,gBAAgB,0BAAyB;AAChD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,YAAY,QAAQ,2BAA0B;AACvD,SAASC,SAAS,QAAQ,4BAA2B;AAErD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EAAEC,YAAYC,cAAc,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOC,QAAQ,EAAE;IAE3E,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACJ,IAAIK,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMR,aAAa,IAAI,CAACS,OAAO,CAACC,WAAW,CAACT,eAAe,CAACU,MAAM;IAClE,MAAMC,YAAYf,aAAa;QAC7BgB,SAAS,IAAI;QACbF,QAAQX;IACV;IACA,IAAIc;IAEJ,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,YAAY,EAAEd,KAAK,EAAE,GAAG,MAAMR,WAAW;QACnEkB,SAAS,IAAI;QACbK,QAAQlB,WAAWkB,MAAM;QACzBC,QAAQjB,IAAIiB,MAAM;QAClBP;QACAT,OAAOC;IACT;IAEA,MAAMgB,uBAAuB,MAAMxB,eAAe;QAChDiB,SAAS,IAAI;QACbQ,gBAAgB;YAAC;gBAAEC,MAAM;oBAAC;iBAAE;gBAAEC,QAAQ;YAAQ;SAAE;QAChDlB;QACAU;QACAC;QACAC;QACAL;QACAT;IACF;IAEA,IAAIiB,sBAAsB,CAAC,EAAE,EAAEI,IAAI;QACjCV,cAAc,MAAMT,GAAGoB,KAAK,CAACb,UAAU,CAACc,SAAS,CAAC;YAChDvB,OAAOV,GAAG,IAAI,CAACkC,MAAM,CAACf,UAAU,CAACY,EAAE,EAAEJ,oBAAoB,CAAC,EAAE,CAACI,EAAE;QACjE;IACF,OAAO;QACL,MAAMI,eAAelC,kBAAkB;YACrCmB,SAAS,IAAI;YACbgB,OAAO;YACPX,QAAQlB,WAAWkB,MAAM;YACzBN;QACF;QAEAgB,aAAazB,KAAK,GAAGA;QAErBW,cAAc,MAAMT,GAAGoB,KAAK,CAACb,UAAU,CAACc,SAAS,CAACE;IACpD;IAEA,MAAME,SAAShC,UAAU;QACvBa,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;QAC3BoB,MAAMjB;QACNI,QAAQlB,WAAWkB,MAAM;IAC3B;IAEA,MAAMb,GAAG2B,MAAM,CAAC,IAAI,CAACL,MAAM,CAACf,UAAU,EAAET,KAAK,CAACV,GAAG,IAAI,CAACkC,MAAM,CAACf,UAAU,CAACY,EAAE,EAAEV,YAAYU,EAAE;IAE1F,OAAOM;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAWtD,eAAO,MAAM,cAAc,EAAE,cAiC5B,CAAA"}
1
+ {"version":3,"file":"deleteVersions.d.ts","sourceRoot":"","sources":["../src/deleteVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAWtD,eAAO,MAAM,cAAc,EAAE,cAqC5B,CAAA"}
@@ -1,11 +1,15 @@
1
1
  import { inArray } from 'drizzle-orm';
2
2
  import { buildVersionCollectionFields } from 'payload/versions';
3
- import toSnakeCase from 'to-snake-case';
4
3
  import { findMany } from './find/findMany.js';
4
+ import { getTableName } from './schema/getTableName.js';
5
5
  export const deleteVersions = async function deleteVersion({ collection, locale, req = {}, where: where }) {
6
6
  const db = this.sessions[req.transactionID]?.db || this.drizzle;
7
7
  const collectionConfig = this.payload.collections[collection].config;
8
- const tableName = `_${toSnakeCase(collection)}_v`;
8
+ const tableName = getTableName({
9
+ adapter: this,
10
+ config: collectionConfig,
11
+ versions: true
12
+ });
9
13
  const fields = buildVersionCollectionFields(collectionConfig);
10
14
  const { docs } = await findMany({
11
15
  adapter: this,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport { inArray } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersion(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where: where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = `_${toSnakeCase(collection)}_v`\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const { docs } = await findMany({\n adapter: this,\n fields,\n limit: 0,\n locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n docs.forEach((doc) => {\n ids.push(doc.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n\n return docs\n}\n"],"names":["inArray","buildVersionCollectionFields","toSnakeCase","findMany","deleteVersions","deleteVersion","collection","locale","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","fields","docs","adapter","limit","page","pagination","ids","forEach","doc","push","id","length","delete","tables"],"mappings":"AAGA,SAASA,OAAO,QAAQ,cAAa;AACrC,SAASC,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,iBAAiC,eAAeC,cAE3D,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOA,KAAK,EAAE;IAEhE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IAE/F,MAAMC,YAAY,CAAC,CAAC,EAAEhB,YAAYI,YAAY,EAAE,CAAC;IACjD,MAAMa,SAASlB,6BAA6Ba;IAE5C,MAAM,EAAEM,IAAI,EAAE,GAAG,MAAMjB,SAAS;QAC9BkB,SAAS,IAAI;QACbF;QACAG,OAAO;QACPf;QACAgB,MAAM;QACNC,YAAY;QACZhB;QACAU;QACAT;IACF;IAEA,MAAMgB,MAAM,EAAE;IAEdL,KAAKM,OAAO,CAAC,CAACC;QACZF,IAAIG,IAAI,CAACD,IAAIE,EAAE;IACjB;IAEA,IAAIJ,IAAIK,MAAM,GAAG,GAAG;QAClB,MAAMpB,GAAGqB,MAAM,CAAC,IAAI,CAACC,MAAM,CAACd,UAAU,EAAET,KAAK,CAACT,QAAQ,IAAI,CAACgC,MAAM,CAACd,UAAU,CAACW,EAAE,EAAEJ;IACnF;IAEA,OAAOL;AACT,EAAC"}
1
+ {"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport { inArray } from 'drizzle-orm'\nimport { buildVersionCollectionFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const deleteVersions: DeleteVersions = async function deleteVersion(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where: where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n versions: true,\n })\n const fields = buildVersionCollectionFields(collectionConfig)\n\n const { docs } = await findMany({\n adapter: this,\n fields,\n limit: 0,\n locale,\n page: 1,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n const ids = []\n\n docs.forEach((doc) => {\n ids.push(doc.id)\n })\n\n if (ids.length > 0) {\n await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids))\n }\n\n return docs\n}\n"],"names":["inArray","buildVersionCollectionFields","findMany","getTableName","deleteVersions","deleteVersion","collection","locale","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","adapter","versions","fields","docs","limit","page","pagination","ids","forEach","doc","push","id","length","delete","tables"],"mappings":"AAGA,SAASA,OAAO,QAAQ,cAAa;AACrC,SAASC,4BAA4B,QAAQ,mBAAkB;AAI/D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,iBAAiC,eAAeC,cAE3D,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOA,KAAK,EAAE;IAEhE,MAAMC,KAAK,IAAI,CAACC,QAAQ,CAACH,IAAII,aAAa,CAAC,EAAEF,MAAM,IAAI,CAACG,OAAO;IAC/D,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACV,WAAW,CAACW,MAAM;IAE/F,MAAMC,YAAYf,aAAa;QAC7BgB,SAAS,IAAI;QACbF,QAAQH;QACRM,UAAU;IACZ;IACA,MAAMC,SAASpB,6BAA6Ba;IAE5C,MAAM,EAAEQ,IAAI,EAAE,GAAG,MAAMpB,SAAS;QAC9BiB,SAAS,IAAI;QACbE;QACAE,OAAO;QACPhB;QACAiB,MAAM;QACNC,YAAY;QACZjB;QACAU;QACAT;IACF;IAEA,MAAMiB,MAAM,EAAE;IAEdJ,KAAKK,OAAO,CAAC,CAACC;QACZF,IAAIG,IAAI,CAACD,IAAIE,EAAE;IACjB;IAEA,IAAIJ,IAAIK,MAAM,GAAG,GAAG;QAClB,MAAMrB,GAAGsB,MAAM,CAAC,IAAI,CAACC,MAAM,CAACf,UAAU,EAAET,KAAK,CAACT,QAAQ,IAAI,CAACiC,MAAM,CAACf,UAAU,CAACY,EAAE,EAAEJ;IACnF;IAEA,OAAOJ;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/find/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAK1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAGlD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,gBAAgB,EAAE,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,gHAUxB,iBAAiB,4BA+InB,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/find/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAI1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAKlD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,gBAAgB,EAAE,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,gHAUxB,iBAAiB,4BAmKnB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-param-reassign */ import { fieldAffectsData, tabHasName } from 'payload/types';
2
- import toSnakeCase from 'to-snake-case';
2
+ import { getTableName } from '../schema/getTableName.js';
3
3
  export const traverseFields = ({ _locales, adapter, currentArgs, currentTableName, depth, fields, path, topLevelArgs, topLevelTableName })=>{
4
4
  fields.forEach((field)=>{
5
5
  if (field.type === 'collapsible' || field.type === 'row') {
@@ -46,8 +46,20 @@ export const traverseFields = ({ _locales, adapter, currentArgs, currentTableNam
46
46
  ],
47
47
  with: {}
48
48
  };
49
- const arrayTableName = `${currentTableName}_${path}${toSnakeCase(field.name)}`;
50
- if (adapter.tables[`${arrayTableName}_locales`]) withArray.with._locales = _locales;
49
+ const arrayTableName = getTableName({
50
+ adapter,
51
+ config: field,
52
+ parentTableName: currentTableName,
53
+ prefix: `${currentTableName}_${path}`
54
+ });
55
+ const arrayTableNameWithLocales = getTableName({
56
+ adapter,
57
+ config: field,
58
+ locales: true,
59
+ parentTableName: currentTableName,
60
+ prefix: `${currentTableName}_${path}`
61
+ });
62
+ if (adapter.tables[arrayTableNameWithLocales]) withArray.with._locales = _locales;
51
63
  currentArgs.with[`${path}${field.name}`] = withArray;
52
64
  traverseFields({
53
65
  _locales,
@@ -92,8 +104,15 @@ export const traverseFields = ({ _locales, adapter, currentArgs, currentTableNam
92
104
  ],
93
105
  with: {}
94
106
  };
95
- const tableName = `${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`;
96
- if (adapter.tables[`${tableName}_locales`]) withBlock.with._locales = _locales;
107
+ const tableName = getTableName({
108
+ adapter,
109
+ config: block,
110
+ parentTableName: topLevelTableName,
111
+ prefix: `${topLevelTableName}_blocks_`
112
+ });
113
+ if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {
114
+ withBlock.with._locales = _locales;
115
+ }
97
116
  topLevelArgs.with[blockKey] = withBlock;
98
117
  traverseFields({
99
118
  _locales,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/find/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData, tabHasName } from 'payload/types'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { Result } from './buildFindManyArgs.js'\n\ntype TraverseFieldArgs = {\n _locales: Record<string, unknown>\n adapter: PostgresAdapter\n currentArgs: Record<string, unknown>\n currentTableName: string\n depth?: number\n fields: Field[]\n path: string\n topLevelArgs: Record<string, unknown>\n topLevelTableName: string\n}\n\nexport const traverseFields = ({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields,\n path,\n topLevelArgs,\n topLevelTableName,\n}: TraverseFieldArgs) => {\n fields.forEach((field) => {\n if (field.type === 'collapsible' || field.type === 'row') {\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path,\n topLevelArgs,\n topLevelTableName,\n })\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path\n\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: tab.fields,\n path: tabPath,\n topLevelArgs,\n topLevelTableName,\n })\n })\n\n return\n }\n\n if (fieldAffectsData(field)) {\n switch (field.type) {\n case 'array': {\n const withArray: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const arrayTableName = `${currentTableName}_${path}${toSnakeCase(field.name)}`\n\n if (adapter.tables[`${arrayTableName}_locales`]) withArray.with._locales = _locales\n currentArgs.with[`${path}${field.name}`] = withArray\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withArray,\n currentTableName: arrayTableName,\n depth,\n fields: field.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n }\n\n case 'select': {\n if (field.hasMany) {\n const withSelect: Result = {\n columns: {\n id: false,\n order: false,\n parent: false,\n },\n orderBy: ({ order }, { asc }) => [asc(order)],\n }\n\n currentArgs.with[`${path}${field.name}`] = withSelect\n }\n\n break\n }\n\n case 'blocks':\n field.blocks.forEach((block) => {\n const blockKey = `_blocks_${block.slug}`\n\n if (!topLevelArgs[blockKey]) {\n const withBlock: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const tableName = `${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`\n\n if (adapter.tables[`${tableName}_locales`]) withBlock.with._locales = _locales\n topLevelArgs.with[blockKey] = withBlock\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withBlock,\n currentTableName: tableName,\n depth,\n fields: block.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n }\n })\n\n break\n\n case 'group':\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path: `${path}${field.name}_`,\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n\n default: {\n break\n }\n }\n }\n })\n\n return topLevelArgs\n}\n"],"names":["fieldAffectsData","tabHasName","toSnakeCase","traverseFields","_locales","adapter","currentArgs","currentTableName","depth","fields","path","topLevelArgs","topLevelTableName","forEach","field","type","tabs","tab","tabPath","name","withArray","columns","_parentID","orderBy","_order","asc","with","arrayTableName","tables","hasMany","withSelect","id","order","parent","blocks","block","blockKey","slug","withBlock","tableName"],"mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,EAAEC,UAAU,QAAQ,gBAAe;AAC5D,OAAOC,iBAAiB,gBAAe;AAiBvC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,YAAY,EACZC,iBAAiB,EACC;IAClBH,OAAOI,OAAO,CAAC,CAACC;QACd,IAAIA,MAAMC,IAAI,KAAK,iBAAiBD,MAAMC,IAAI,KAAK,OAAO;YACxDZ,eAAe;gBACbC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,QAAQK,MAAML,MAAM;gBACpBC;gBACAC;gBACAC;YACF;YAEA;QACF;QAEA,IAAIE,MAAMC,IAAI,KAAK,QAAQ;YACzBD,MAAME,IAAI,CAACH,OAAO,CAAC,CAACI;gBAClB,MAAMC,UAAUjB,WAAWgB,OAAO,CAAC,EAAEP,KAAK,EAAEO,IAAIE,IAAI,CAAC,CAAC,CAAC,GAAGT;gBAE1DP,eAAe;oBACbC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,QAAQQ,IAAIR,MAAM;oBAClBC,MAAMQ;oBACNP;oBACAC;gBACF;YACF;YAEA;QACF;QAEA,IAAIZ,iBAAiBc,QAAQ;YAC3B,OAAQA,MAAMC,IAAI;gBAChB,KAAK;oBAAS;wBACZ,MAAMK,YAAoB;4BACxBC,SAAS;gCACPC,WAAW;4BACb;4BACAC,SAAS,CAAC,EAAEC,MAAM,EAAE,EAAE,EAAEC,GAAG,EAAE,GAAK;oCAACA,IAAID;iCAAQ;4BAC/CE,MAAM,CAAC;wBACT;wBAEA,MAAMC,iBAAiB,CAAC,EAAEpB,iBAAiB,CAAC,EAAEG,KAAK,EAAER,YAAYY,MAAMK,IAAI,EAAE,CAAC;wBAE9E,IAAId,QAAQuB,MAAM,CAAC,CAAC,EAAED,eAAe,QAAQ,CAAC,CAAC,EAAEP,UAAUM,IAAI,CAACtB,QAAQ,GAAGA;wBAC3EE,YAAYoB,IAAI,CAAC,CAAC,EAAEhB,KAAK,EAAEI,MAAMK,IAAI,CAAC,CAAC,CAAC,GAAGC;wBAE3CjB,eAAe;4BACbC;4BACAC;4BACAC,aAAac;4BACbb,kBAAkBoB;4BAClBnB;4BACAC,QAAQK,MAAML,MAAM;4BACpBC,MAAM;4BACNC;4BACAC;wBACF;wBAEA;oBACF;gBAEA,KAAK;oBAAU;wBACb,IAAIE,MAAMe,OAAO,EAAE;4BACjB,MAAMC,aAAqB;gCACzBT,SAAS;oCACPU,IAAI;oCACJC,OAAO;oCACPC,QAAQ;gCACV;gCACAV,SAAS,CAAC,EAAES,KAAK,EAAE,EAAE,EAAEP,GAAG,EAAE,GAAK;wCAACA,IAAIO;qCAAO;4BAC/C;4BAEA1B,YAAYoB,IAAI,CAAC,CAAC,EAAEhB,KAAK,EAAEI,MAAMK,IAAI,CAAC,CAAC,CAAC,GAAGW;wBAC7C;wBAEA;oBACF;gBAEA,KAAK;oBACHhB,MAAMoB,MAAM,CAACrB,OAAO,CAAC,CAACsB;wBACpB,MAAMC,WAAW,CAAC,QAAQ,EAAED,MAAME,IAAI,CAAC,CAAC;wBAExC,IAAI,CAAC1B,YAAY,CAACyB,SAAS,EAAE;4BAC3B,MAAME,YAAoB;gCACxBjB,SAAS;oCACPC,WAAW;gCACb;gCACAC,SAAS,CAAC,EAAEC,MAAM,EAAE,EAAE,EAAEC,GAAG,EAAE,GAAK;wCAACA,IAAID;qCAAQ;gCAC/CE,MAAM,CAAC;4BACT;4BAEA,MAAMa,YAAY,CAAC,EAAE3B,kBAAkB,QAAQ,EAAEV,YAAYiC,MAAME,IAAI,EAAE,CAAC;4BAE1E,IAAIhC,QAAQuB,MAAM,CAAC,CAAC,EAAEW,UAAU,QAAQ,CAAC,CAAC,EAAED,UAAUZ,IAAI,CAACtB,QAAQ,GAAGA;4BACtEO,aAAae,IAAI,CAACU,SAAS,GAAGE;4BAE9BnC,eAAe;gCACbC;gCACAC;gCACAC,aAAagC;gCACb/B,kBAAkBgC;gCAClB/B;gCACAC,QAAQ0B,MAAM1B,MAAM;gCACpBC,MAAM;gCACNC;gCACAC;4BACF;wBACF;oBACF;oBAEA;gBAEF,KAAK;oBACHT,eAAe;wBACbC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC,QAAQK,MAAML,MAAM;wBACpBC,MAAM,CAAC,EAAEA,KAAK,EAAEI,MAAMK,IAAI,CAAC,CAAC,CAAC;wBAC7BR;wBACAC;oBACF;oBAEA;gBAEF;oBAAS;wBACP;oBACF;YACF;QACF;IACF;IAEA,OAAOD;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/find/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData, tabHasName } from 'payload/types'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { Result } from './buildFindManyArgs.js'\n\nimport { getTableName } from '../schema/getTableName.js'\n\ntype TraverseFieldArgs = {\n _locales: Record<string, unknown>\n adapter: PostgresAdapter\n currentArgs: Record<string, unknown>\n currentTableName: string\n depth?: number\n fields: Field[]\n path: string\n topLevelArgs: Record<string, unknown>\n topLevelTableName: string\n}\n\nexport const traverseFields = ({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields,\n path,\n topLevelArgs,\n topLevelTableName,\n}: TraverseFieldArgs) => {\n fields.forEach((field) => {\n if (field.type === 'collapsible' || field.type === 'row') {\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path,\n topLevelArgs,\n topLevelTableName,\n })\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path\n\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: tab.fields,\n path: tabPath,\n topLevelArgs,\n topLevelTableName,\n })\n })\n\n return\n }\n\n if (fieldAffectsData(field)) {\n switch (field.type) {\n case 'array': {\n const withArray: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const arrayTableName = getTableName({\n adapter,\n config: field,\n parentTableName: currentTableName,\n prefix: `${currentTableName}_${path}`,\n })\n\n const arrayTableNameWithLocales = getTableName({\n adapter,\n config: field,\n locales: true,\n parentTableName: currentTableName,\n prefix: `${currentTableName}_${path}`,\n })\n\n if (adapter.tables[arrayTableNameWithLocales]) withArray.with._locales = _locales\n currentArgs.with[`${path}${field.name}`] = withArray\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withArray,\n currentTableName: arrayTableName,\n depth,\n fields: field.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n }\n\n case 'select': {\n if (field.hasMany) {\n const withSelect: Result = {\n columns: {\n id: false,\n order: false,\n parent: false,\n },\n orderBy: ({ order }, { asc }) => [asc(order)],\n }\n\n currentArgs.with[`${path}${field.name}`] = withSelect\n }\n\n break\n }\n\n case 'blocks':\n field.blocks.forEach((block) => {\n const blockKey = `_blocks_${block.slug}`\n\n if (!topLevelArgs[blockKey]) {\n const withBlock: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const tableName = getTableName({\n adapter,\n config: block,\n parentTableName: topLevelTableName,\n prefix: `${topLevelTableName}_blocks_`,\n })\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n withBlock.with._locales = _locales\n }\n topLevelArgs.with[blockKey] = withBlock\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withBlock,\n currentTableName: tableName,\n depth,\n fields: block.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n }\n })\n\n break\n\n case 'group':\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path: `${path}${field.name}_`,\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n\n default: {\n break\n }\n }\n }\n })\n\n return topLevelArgs\n}\n"],"names":["fieldAffectsData","tabHasName","getTableName","traverseFields","_locales","adapter","currentArgs","currentTableName","depth","fields","path","topLevelArgs","topLevelTableName","forEach","field","type","tabs","tab","tabPath","name","withArray","columns","_parentID","orderBy","_order","asc","with","arrayTableName","config","parentTableName","prefix","arrayTableNameWithLocales","locales","tables","hasMany","withSelect","id","order","parent","blocks","block","blockKey","slug","withBlock","tableName","localesSuffix"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAS5C,eAAO,MAAM,IAAI,EAAE,IA4BlB,CAAA"}
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAQ5C,eAAO,MAAM,IAAI,EAAE,IAgClB,CAAA"}
package/dist/find.js CHANGED
@@ -1,19 +1,23 @@
1
- import toSnakeCase from 'to-snake-case';
2
1
  import { findMany } from './find/findMany.js';
3
- export const find = async function find({ collection, limit: limitArg, locale, page = 1, pagination, req = {}, sort: sortArg, where: whereArg }) {
2
+ import { getTableName } from './schema/getTableName.js';
3
+ export const find = async function find({ collection, limit, locale, page = 1, pagination, req = {}, sort: sortArg, where }) {
4
4
  const collectionConfig = this.payload.collections[collection].config;
5
5
  const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
6
+ const tableName = getTableName({
7
+ adapter: this,
8
+ config: collectionConfig
9
+ });
6
10
  return findMany({
7
11
  adapter: this,
8
12
  fields: collectionConfig.fields,
9
- limit: limitArg,
13
+ limit,
10
14
  locale,
11
15
  page,
12
16
  pagination,
13
17
  req,
14
18
  sort,
15
- tableName: toSnakeCase(collection),
16
- where: whereArg
19
+ tableName,
20
+ where
17
21
  });
18
22
  };
19
23
 
package/dist/find.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const find: Find = async function find(\n this: PostgresAdapter,\n {\n collection,\n limit: limitArg,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n sort: sortArg,\n where: whereArg,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n return findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: limitArg,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName: toSnakeCase(collection),\n where: whereArg,\n })\n}\n"],"names":["toSnakeCase","findMany","find","collection","limit","limitArg","locale","page","pagination","req","sort","sortArg","where","whereArg","collectionConfig","payload","collections","config","defaultSort","adapter","fields","tableName"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,OAAOC,QAAQ,EACfC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAMC,OAAO,EACbC,OAAOC,QAAQ,EAChB;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACb,WAAW,CAACc,MAAM;IAC/F,MAAMP,OAAO,OAAOC,YAAY,WAAWA,UAAUG,iBAAiBI,WAAW;IAEjF,OAAOjB,SAAS;QACdkB,SAAS,IAAI;QACbC,QAAQN,iBAAiBM,MAAM;QAC/BhB,OAAOC;QACPC;QACAC;QACAC;QACAC;QACAC;QACAW,WAAWrB,YAAYG;QACvBS,OAAOC;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const find: Find = async function find(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n })\n\n return findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["findMany","getTableName","find","collection","limit","locale","page","pagination","req","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","adapter","fields"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACX,WAAW,CAACY,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IACjF,MAAMC,YAAYhB,aAAa;QAC7BiB,SAAS,IAAI;QACbH,QAAQH;IACV;IAEA,OAAOZ,SAAS;QACdkB,SAAS,IAAI;QACbC,QAAQP,iBAAiBO,MAAM;QAC/Bf;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAQlD,eAAO,MAAM,UAAU,EAAE,UA0BxB,CAAA"}
1
+ {"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOlD,eAAO,MAAM,UAAU,EAAE,UA6BxB,CAAA"}
@@ -1,8 +1,11 @@
1
- import toSnakeCase from 'to-snake-case';
2
1
  import { findMany } from './find/findMany.js';
2
+ import { getTableName } from './schema/getTableName.js';
3
3
  export const findGlobal = async function findGlobal({ slug, locale, req, where }) {
4
4
  const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
5
- const tableName = toSnakeCase(slug);
5
+ const tableName = getTableName({
6
+ adapter: this,
7
+ config: globalConfig
8
+ });
6
9
  const { docs: [doc] } = await findMany({
7
10
  adapter: this,
8
11
  fields: globalConfig.fields,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload/database'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: PostgresAdapter,\n { slug, locale, req, where },\n) {\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = toSnakeCase(slug)\n\n const {\n docs: [doc],\n } = await findMany({\n adapter: this,\n fields: globalConfig.fields,\n limit: 1,\n locale,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n if (doc) {\n doc.globalType = slug\n return doc\n }\n\n return {}\n}\n"],"names":["toSnakeCase","findMany","findGlobal","slug","locale","req","where","globalConfig","payload","globals","config","find","tableName","docs","doc","adapter","fields","limit","pagination","globalType"],"mappings":"AAEA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE5B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOP,IAAI,KAAKA;IAClF,MAAMS,YAAYZ,YAAYG;IAE9B,MAAM,EACJU,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMb,SAAS;QACjBc,SAAS,IAAI;QACbC,QAAQT,aAAaS,MAAM;QAC3BC,OAAO;QACPb;QACAc,YAAY;QACZb;QACAO;QACAN;IACF;IAEA,IAAIQ,KAAK;QACPA,IAAIK,UAAU,GAAGhB;QACjB,OAAOW;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
1
+ {"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: PostgresAdapter,\n { slug, locale, req, where },\n) {\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = getTableName({\n adapter: this,\n config: globalConfig,\n })\n\n const {\n docs: [doc],\n } = await findMany({\n adapter: this,\n fields: globalConfig.fields,\n limit: 1,\n locale,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n if (doc) {\n doc.globalType = slug\n return doc\n }\n\n return {}\n}\n"],"names":["findMany","getTableName","findGlobal","slug","locale","req","where","globalConfig","payload","globals","config","find","tableName","adapter","docs","doc","fields","limit","pagination","globalType"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE5B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOP,IAAI,KAAKA;IAClF,MAAMS,YAAYX,aAAa;QAC7BY,SAAS,IAAI;QACbH,QAAQH;IACV;IAEA,MAAM,EACJO,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMf,SAAS;QACjBa,SAAS,IAAI;QACbG,QAAQT,aAAaS,MAAM;QAC3BC,OAAO;QACPb;QACAc,YAAY;QACZb;QACAO;QACAN;IACF;IAEA,IAAIS,KAAK;QACPA,IAAII,UAAU,GAAGhB;QACjB,OAAOY;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAU1D,eAAO,MAAM,kBAAkB,EAAE,kBAmChC,CAAA"}
1
+ {"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAU1D,eAAO,MAAM,kBAAkB,EAAE,kBAuChC,CAAA"}
@@ -1,10 +1,14 @@
1
1
  import { buildVersionGlobalFields } from 'payload/versions';
2
- import toSnakeCase from 'to-snake-case';
3
2
  import { findMany } from './find/findMany.js';
3
+ import { getTableName } from './schema/getTableName.js';
4
4
  export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
5
5
  const globalConfig = this.payload.globals.config.find(({ slug })=>slug === global);
6
6
  const sort = typeof sortArg === 'string' ? sortArg : '-createdAt';
7
- const tableName = `_${toSnakeCase(global)}_v`;
7
+ const tableName = getTableName({
8
+ adapter: this,
9
+ config: globalConfig,
10
+ versions: true
11
+ });
8
12
  const fields = buildVersionGlobalFields(globalConfig);
9
13
  return findMany({
10
14
  adapter: this,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { FindGlobalVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedGlobalConfig } from 'payload/types'\n\nimport { buildVersionGlobalFields } from 'payload/versions'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: PostgresAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const sort = typeof sortArg === 'string' ? sortArg : '-createdAt'\n\n const tableName = `_${toSnakeCase(global)}_v`\n const fields = buildVersionGlobalFields(globalConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionGlobalFields","toSnakeCase","findMany","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","tableName","fields","adapter"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,mBAAkB;AAC3D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASf;IAEzB,MAAMO,OAAO,OAAOC,YAAY,WAAWA,UAAU;IAErD,MAAMQ,YAAY,CAAC,CAAC,EAAEnB,YAAYG,QAAQ,EAAE,CAAC;IAC7C,MAAMiB,SAASrB,yBAAyBc;IAExC,OAAOZ,SAAS;QACdoB,SAAS,IAAI;QACbD;QACAhB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { FindGlobalVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedGlobalConfig } from 'payload/types'\n\nimport { buildVersionGlobalFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: PostgresAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const sort = typeof sortArg === 'string' ? sortArg : '-createdAt'\n\n const tableName = getTableName({\n adapter: this,\n config: globalConfig,\n versions: true,\n })\n const fields = buildVersionGlobalFields(globalConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionGlobalFields","findMany","getTableName","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","tableName","adapter","versions","fields"],"mappings":"AAGA,SAASA,wBAAwB,QAAQ,mBAAkB;AAI3D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASf;IAEzB,MAAMO,OAAO,OAAOC,YAAY,WAAWA,UAAU;IAErD,MAAMQ,YAAYlB,aAAa;QAC7BmB,SAAS,IAAI;QACbJ,QAAQH;QACRQ,UAAU;IACZ;IACA,MAAMC,SAASvB,yBAAyBc;IAExC,OAAOb,SAAS;QACdoB,SAAS,IAAI;QACbE;QACAlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
package/dist/findOne.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { FindOneArgs } from 'payload/database';
2
2
  import type { TypeWithID } from 'payload/types';
3
3
  import type { PostgresAdapter } from './types.js';
4
- export declare function findOne<T extends TypeWithID>(this: PostgresAdapter, { collection, locale, req, where: incomingWhere }: FindOneArgs): Promise<T>;
4
+ export declare function findOne<T extends TypeWithID>(this: PostgresAdapter, { collection, locale, req, where }: FindOneArgs): Promise<T>;
5
5
  //# sourceMappingURL=findOne.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAA6C,UAAU,EAAE,MAAM,eAAe,CAAA;AAI1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAIjD,wBAAsB,OAAO,CAAC,CAAC,SAAS,UAAU,EAChD,IAAI,EAAE,eAAe,EACrB,EAAE,UAAU,EAAE,MAAM,EAAE,GAA0B,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,WAAW,GACpF,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
1
+ {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAA6C,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKjD,wBAAsB,OAAO,CAAC,CAAC,SAAS,UAAU,EAChD,IAAI,EAAE,eAAe,EACrB,EAAE,UAAU,EAAE,MAAM,EAAE,GAA0B,EAAE,KAAK,EAAE,EAAE,WAAW,GACrE,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
package/dist/findOne.js CHANGED
@@ -1,7 +1,11 @@
1
- import toSnakeCase from 'to-snake-case';
2
1
  import { findMany } from './find/findMany.js';
3
- export async function findOne({ collection, locale, req = {}, where: incomingWhere }) {
2
+ import { getTableName } from './schema/getTableName.js';
3
+ export async function findOne({ collection, locale, req = {}, where }) {
4
4
  const collectionConfig = this.payload.collections[collection].config;
5
+ const tableName = getTableName({
6
+ adapter: this,
7
+ config: collectionConfig
8
+ });
5
9
  const { docs } = await findMany({
6
10
  adapter: this,
7
11
  fields: collectionConfig.fields,
@@ -11,8 +15,8 @@ export async function findOne({ collection, locale, req = {}, where: incomingWhe
11
15
  pagination: false,
12
16
  req,
13
17
  sort: undefined,
14
- tableName: toSnakeCase(collection),
15
- where: incomingWhere
18
+ tableName,
19
+ where
16
20
  });
17
21
  return docs?.[0] || null;
18
22
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOneArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\n\nexport async function findOne<T extends TypeWithID>(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where: incomingWhere }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const { docs } = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 1,\n locale,\n page: 1,\n pagination: false,\n req,\n sort: undefined,\n tableName: toSnakeCase(collection),\n where: incomingWhere,\n })\n\n return docs?.[0] || null\n}\n"],"names":["toSnakeCase","findMany","findOne","collection","locale","req","where","incomingWhere","collectionConfig","payload","collections","config","docs","adapter","fields","limit","page","pagination","sort","undefined","tableName"],"mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,OAAOC,aAAa,EAAe;IAErF,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACP,WAAW,CAACQ,MAAM;IAE/F,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMX,SAAS;QAC9BY,SAAS,IAAI;QACbC,QAAQN,iBAAiBM,MAAM;QAC/BC,OAAO;QACPX;QACAY,MAAM;QACNC,YAAY;QACZZ;QACAa,MAAMC;QACNC,WAAWpB,YAAYG;QACvBG,OAAOC;IACT;IAEA,OAAOK,MAAM,CAAC,EAAE,IAAI;AACtB"}
1
+ {"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOneArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport async function findOne<T extends TypeWithID>(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n })\n\n const { docs } = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 1,\n locale,\n page: 1,\n pagination: false,\n req,\n sort: undefined,\n tableName,\n where,\n })\n\n return docs?.[0] || null\n}\n"],"names":["findMany","getTableName","findOne","collection","locale","req","where","collectionConfig","payload","collections","config","tableName","adapter","docs","fields","limit","page","pagination","sort","undefined"],"mappings":"AAKA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAe;IAEtE,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACN,WAAW,CAACO,MAAM;IAC/F,MAAMC,YAAYV,aAAa;QAC7BW,SAAS,IAAI;QACbF,QAAQH;IACV;IAEA,MAAM,EAAEM,IAAI,EAAE,GAAG,MAAMb,SAAS;QAC9BY,SAAS,IAAI;QACbE,QAAQP,iBAAiBO,MAAM;QAC/BC,OAAO;QACPX;QACAY,MAAM;QACNC,YAAY;QACZZ;QACAa,MAAMC;QACNR;QACAL;IACF;IAEA,OAAOO,MAAM,CAAC,EAAE,IAAI;AACtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAUpD,eAAO,MAAM,YAAY,EAAE,YAiC1B,CAAA"}
1
+ {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAUpD,eAAO,MAAM,YAAY,EAAE,YAqC1B,CAAA"}