@payloadcms/db-postgres 3.0.0-canary.f6e77b8 → 3.0.0-canary.fb04843
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/dist/connect.d.ts +1 -1
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +45 -17
- package/dist/connect.js.map +1 -1
- package/dist/exports/migration-utils.d.ts +2 -0
- package/dist/exports/migration-utils.d.ts.map +1 -0
- package/dist/exports/migration-utils.js +3 -0
- package/dist/exports/migration-utils.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -69
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
- package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
- package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +196 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/index.js +211 -0
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +63 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
- package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/types.js +6 -0
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
- package/dist/types.d.ts +65 -77
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/license.md +22 -0
- package/package.json +35 -17
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -50
- package/dist/count.js.map +0 -1
- package/dist/create.d.ts +0 -3
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -19
- package/dist/create.js.map +0 -1
- package/dist/createGlobal.d.ts +0 -5
- package/dist/createGlobal.d.ts.map +0 -1
- package/dist/createGlobal.js +0 -19
- package/dist/createGlobal.js.map +0 -1
- package/dist/createGlobalVersion.d.ts +0 -6
- package/dist/createGlobalVersion.d.ts.map +0 -1
- package/dist/createGlobalVersion.js +0 -33
- package/dist/createGlobalVersion.js.map +0 -1
- package/dist/createMigration.d.ts +0 -3
- package/dist/createMigration.d.ts.map +0 -1
- package/dist/createMigration.js +0 -81
- package/dist/createMigration.js.map +0 -1
- package/dist/createVersion.d.ts +0 -5
- package/dist/createVersion.d.ts.map +0 -1
- package/dist/createVersion.js +0 -44
- package/dist/createVersion.js.map +0 -1
- package/dist/deleteMany.d.ts +0 -3
- package/dist/deleteMany.d.ts.map +0 -1
- package/dist/deleteMany.js +0 -28
- package/dist/deleteMany.js.map +0 -1
- package/dist/deleteOne.d.ts +0 -3
- package/dist/deleteOne.d.ts.map +0 -1
- package/dist/deleteOne.js +0 -59
- package/dist/deleteOne.js.map +0 -1
- package/dist/deleteVersions.d.ts +0 -3
- package/dist/deleteVersions.d.ts.map +0 -1
- package/dist/deleteVersions.js +0 -31
- package/dist/deleteVersions.js.map +0 -1
- package/dist/destroy.d.ts +0 -3
- package/dist/destroy.d.ts.map +0 -1
- package/dist/destroy.js +0 -11
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -13
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -64
- package/dist/find/buildFindManyArgs.js.map +0 -1
- package/dist/find/chainMethods.d.ts +0 -16
- package/dist/find/chainMethods.d.ts.map +0 -1
- package/dist/find/chainMethods.js +0 -12
- package/dist/find/chainMethods.js.map +0 -1
- package/dist/find/findMany.d.ts +0 -22
- package/dist/find/findMany.d.ts.map +0 -1
- package/dist/find/findMany.js +0 -163
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -16
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -138
- package/dist/find/traverseFields.js.map +0 -1
- package/dist/find.d.ts +0 -3
- package/dist/find.d.ts.map +0 -1
- package/dist/find.js +0 -21
- package/dist/find.js.map +0 -1
- package/dist/findGlobal.d.ts +0 -3
- package/dist/findGlobal.d.ts.map +0 -1
- package/dist/findGlobal.js +0 -23
- package/dist/findGlobal.js.map +0 -1
- package/dist/findGlobalVersions.d.ts +0 -3
- package/dist/findGlobalVersions.d.ts.map +0 -1
- package/dist/findGlobalVersions.js +0 -24
- package/dist/findGlobalVersions.js.map +0 -1
- package/dist/findOne.d.ts +0 -5
- package/dist/findOne.d.ts.map +0 -1
- package/dist/findOne.js +0 -21
- package/dist/findOne.js.map +0 -1
- package/dist/findVersions.d.ts +0 -3
- package/dist/findVersions.d.ts.map +0 -1
- package/dist/findVersions.js +0 -24
- package/dist/findVersions.js.map +0 -1
- package/dist/init.d.ts +0 -3
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -96
- package/dist/init.js.map +0 -1
- package/dist/migrate.d.ts +0 -3
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js +0 -99
- package/dist/migrate.js.map +0 -1
- package/dist/migrateDown.d.ts +0 -3
- package/dist/migrateDown.d.ts.map +0 -1
- package/dist/migrateDown.js +0 -63
- package/dist/migrateDown.js.map +0 -1
- package/dist/migrateFresh.d.ts +0 -8
- package/dist/migrateFresh.d.ts.map +0 -1
- package/dist/migrateFresh.js +0 -72
- package/dist/migrateFresh.js.map +0 -1
- package/dist/migrateRefresh.d.ts +0 -6
- package/dist/migrateRefresh.d.ts.map +0 -1
- package/dist/migrateRefresh.js +0 -102
- package/dist/migrateRefresh.js.map +0 -1
- package/dist/migrateReset.d.ts +0 -6
- package/dist/migrateReset.d.ts.map +0 -1
- package/dist/migrateReset.js +0 -82
- package/dist/migrateReset.js.map +0 -1
- package/dist/migrateStatus.d.ts +0 -3
- package/dist/migrateStatus.d.ts.map +0 -1
- package/dist/migrateStatus.js +0 -44
- package/dist/migrateStatus.js.map +0 -1
- package/dist/queries/buildAndOrConditions.d.ts +0 -17
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -29
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -31
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -76
- package/dist/queries/buildQuery.js.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
- package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
- package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
- package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
- package/dist/queries/createJSONQuery/index.d.ts +0 -10
- package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
- package/dist/queries/createJSONQuery/index.js +0 -54
- package/dist/queries/createJSONQuery/index.js.map +0 -1
- package/dist/queries/getTableColumnFromPath.d.ts +0 -51
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -445
- package/dist/queries/getTableColumnFromPath.js.map +0 -1
- package/dist/queries/operatorMap.d.ts +0 -18
- package/dist/queries/operatorMap.d.ts.map +0 -1
- package/dist/queries/operatorMap.js +0 -24
- package/dist/queries/operatorMap.js.map +0 -1
- package/dist/queries/parseParams.d.ts +0 -17
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -182
- package/dist/queries/parseParams.js.map +0 -1
- package/dist/queries/sanitizeQueryValue.d.ts +0 -15
- package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
- package/dist/queries/sanitizeQueryValue.js +0 -90
- package/dist/queries/sanitizeQueryValue.js.map +0 -1
- package/dist/queries/selectDistinct.d.ts +0 -23
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -41
- package/dist/queries/selectDistinct.js.map +0 -1
- package/dist/queryDrafts.d.ts +0 -3
- package/dist/queryDrafts.d.ts.map +0 -1
- package/dist/queryDrafts.js +0 -41
- package/dist/queryDrafts.js.map +0 -1
- package/dist/schema/build.d.ts +0 -30
- package/dist/schema/build.d.ts.map +0 -1
- package/dist/schema/build.js +0 -320
- package/dist/schema/build.js.map +0 -1
- package/dist/schema/createIndex.d.ts +0 -12
- package/dist/schema/createIndex.d.ts.map +0 -1
- package/dist/schema/createIndex.js +0 -18
- package/dist/schema/createIndex.js.map +0 -1
- package/dist/schema/createTableName.d.ts +0 -30
- package/dist/schema/createTableName.d.ts.map +0 -1
- package/dist/schema/createTableName.js +0 -31
- package/dist/schema/createTableName.js.map +0 -1
- package/dist/schema/idToUUID.d.ts +0 -3
- package/dist/schema/idToUUID.d.ts.map +0 -1
- package/dist/schema/idToUUID.js +0 -11
- package/dist/schema/idToUUID.js.map +0 -1
- package/dist/schema/parentIDColumnMap.d.ts +0 -4
- package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
- package/dist/schema/parentIDColumnMap.js +0 -9
- package/dist/schema/parentIDColumnMap.js.map +0 -1
- package/dist/schema/setColumnID.d.ts +0 -11
- package/dist/schema/setColumnID.d.ts.map +0 -1
- package/dist/schema/setColumnID.js +0 -24
- package/dist/schema/setColumnID.js.map +0 -1
- package/dist/schema/traverseFields.d.ts +0 -38
- package/dist/schema/traverseFields.d.ts.map +0 -1
- package/dist/schema/traverseFields.js +0 -551
- package/dist/schema/traverseFields.js.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
- package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
- package/dist/transactions/beginTransaction.d.ts +0 -3
- package/dist/transactions/beginTransaction.d.ts.map +0 -1
- package/dist/transactions/beginTransaction.js +0 -47
- package/dist/transactions/beginTransaction.js.map +0 -1
- package/dist/transactions/commitTransaction.d.ts +0 -3
- package/dist/transactions/commitTransaction.d.ts.map +0 -1
- package/dist/transactions/commitTransaction.js +0 -14
- package/dist/transactions/commitTransaction.js.map +0 -1
- package/dist/transactions/rollbackTransaction.d.ts +0 -3
- package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
- package/dist/transactions/rollbackTransaction.js +0 -13
- package/dist/transactions/rollbackTransaction.js.map +0 -1
- package/dist/transform/read/hasManyNumber.d.ts +0 -10
- package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
- package/dist/transform/read/hasManyNumber.js +0 -10
- package/dist/transform/read/hasManyNumber.js.map +0 -1
- package/dist/transform/read/hasManyText.d.ts +0 -10
- package/dist/transform/read/hasManyText.d.ts.map +0 -1
- package/dist/transform/read/hasManyText.js +0 -10
- package/dist/transform/read/hasManyText.js.map +0 -1
- package/dist/transform/read/index.d.ts +0 -12
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -43
- package/dist/transform/read/index.js.map +0 -1
- package/dist/transform/read/relationship.d.ts +0 -10
- package/dist/transform/read/relationship.d.ts.map +0 -1
- package/dist/transform/read/relationship.js +0 -64
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -52
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -421
- package/dist/transform/read/traverseFields.js.map +0 -1
- package/dist/transform/write/array.d.ts +0 -26
- package/dist/transform/write/array.d.ts.map +0 -1
- package/dist/transform/write/array.js +0 -58
- package/dist/transform/write/array.js.map +0 -1
- package/dist/transform/write/blocks.d.ts +0 -25
- package/dist/transform/write/blocks.d.ts.map +0 -1
- package/dist/transform/write/blocks.js +0 -54
- package/dist/transform/write/blocks.js.map +0 -1
- package/dist/transform/write/index.d.ts +0 -13
- package/dist/transform/write/index.d.ts.map +0 -1
- package/dist/transform/write/index.js +0 -41
- package/dist/transform/write/index.js.map +0 -1
- package/dist/transform/write/numbers.d.ts +0 -8
- package/dist/transform/write/numbers.d.ts.map +0 -1
- package/dist/transform/write/numbers.js +0 -11
- package/dist/transform/write/numbers.js.map +0 -1
- package/dist/transform/write/relationships.d.ts +0 -10
- package/dist/transform/write/relationships.d.ts.map +0 -1
- package/dist/transform/write/relationships.js +0 -23
- package/dist/transform/write/relationships.js.map +0 -1
- package/dist/transform/write/selects.d.ts +0 -8
- package/dist/transform/write/selects.d.ts.map +0 -1
- package/dist/transform/write/selects.js +0 -20
- package/dist/transform/write/selects.js.map +0 -1
- package/dist/transform/write/texts.d.ts +0 -8
- package/dist/transform/write/texts.d.ts.map +0 -1
- package/dist/transform/write/texts.js +0 -11
- package/dist/transform/write/texts.js.map +0 -1
- package/dist/transform/write/traverseFields.d.ts +0 -50
- package/dist/transform/write/traverseFields.d.ts.map +0 -1
- package/dist/transform/write/traverseFields.js +0 -428
- package/dist/transform/write/traverseFields.js.map +0 -1
- package/dist/transform/write/types.d.ts +0 -43
- package/dist/transform/write/types.d.ts.map +0 -1
- package/dist/transform/write/types.js +0 -3
- package/dist/transform/write/types.js.map +0 -1
- package/dist/update.d.ts +0 -3
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js +0 -55
- package/dist/update.js.map +0 -1
- package/dist/updateGlobal.d.ts +0 -5
- package/dist/updateGlobal.d.ts.map +0 -1
- package/dist/updateGlobal.js +0 -25
- package/dist/updateGlobal.js.map +0 -1
- package/dist/updateGlobalVersion.d.ts +0 -5
- package/dist/updateGlobalVersion.d.ts.map +0 -1
- package/dist/updateGlobalVersion.js +0 -36
- package/dist/updateGlobalVersion.js.map +0 -1
- package/dist/updateVersion.d.ts +0 -5
- package/dist/updateVersion.d.ts.map +0 -1
- package/dist/updateVersion.js +0 -36
- package/dist/updateVersion.js.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
- package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
- package/dist/upsertRow/index.d.ts +0 -4
- package/dist/upsertRow/index.d.ts.map +0 -1
- package/dist/upsertRow/index.js +0 -277
- package/dist/upsertRow/index.js.map +0 -1
- package/dist/upsertRow/insertArrays.d.ts +0 -13
- package/dist/upsertRow/insertArrays.d.ts.map +0 -1
- package/dist/upsertRow/insertArrays.js +0 -68
- package/dist/upsertRow/insertArrays.js.map +0 -1
- package/dist/upsertRow/types.d.ts +0 -27
- package/dist/upsertRow/types.d.ts.map +0 -1
- package/dist/upsertRow/types.js +0 -3
- package/dist/upsertRow/types.js.map +0 -1
- package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
- package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
- package/dist/utilities/appendPrefixToKeys.js +0 -6
- package/dist/utilities/appendPrefixToKeys.js.map +0 -1
- package/dist/utilities/createBlocksMap.d.ts +0 -5
- package/dist/utilities/createBlocksMap.d.ts.map +0 -1
- package/dist/utilities/createBlocksMap.js +0 -29
- package/dist/utilities/createBlocksMap.js.map +0 -1
- package/dist/utilities/createMigrationTable.d.ts +0 -3
- package/dist/utilities/createMigrationTable.d.ts.map +0 -1
- package/dist/utilities/createMigrationTable.js +0 -13
- package/dist/utilities/createMigrationTable.js.map +0 -1
- package/dist/utilities/createRelationshipMap.d.ts +0 -2
- package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
- package/dist/utilities/createRelationshipMap.js +0 -19
- package/dist/utilities/createRelationshipMap.js.map +0 -1
- package/dist/utilities/hasLocalesTable.d.ts +0 -3
- package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
- package/dist/utilities/hasLocalesTable.js +0 -11
- package/dist/utilities/hasLocalesTable.js.map +0 -1
- package/dist/utilities/isArrayOfRows.d.ts +0 -2
- package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
- package/dist/utilities/isArrayOfRows.js +0 -5
- package/dist/utilities/isArrayOfRows.js.map +0 -1
- package/dist/utilities/migrationTableExists.d.ts +0 -3
- package/dist/utilities/migrationTableExists.d.ts.map +0 -1
- package/dist/utilities/migrationTableExists.js +0 -9
- package/dist/utilities/migrationTableExists.js.map +0 -1
- package/dist/utilities/parseError.d.ts +0 -5
- package/dist/utilities/parseError.d.ts.map +0 -1
- package/dist/utilities/parseError.js +0 -17
- package/dist/utilities/parseError.js.map +0 -1
- package/dist/utilities/pushDevSchema.d.ts +0 -9
- package/dist/utilities/pushDevSchema.d.ts.map +0 -1
- package/dist/utilities/pushDevSchema.js +0 -58
- package/dist/utilities/pushDevSchema.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/createMigration.ts"],"sourcesContent":["/* eslint-disable no-restricted-syntax, no-await-in-loop */\nimport type { DrizzleSnapshotJSON } from 'drizzle-kit/payload'\nimport type { CreateMigration } from 'payload/database'\n\nimport fs from 'fs'\nimport { createRequire } from 'module'\nimport prompts from 'prompts'\n\nimport type { PostgresAdapter } from './types.js'\n\nconst require = createRequire(import.meta.url)\n\nconst migrationTemplate = (\n upSQL?: string,\n downSQL?: string,\n) => `import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'\n\nexport async function up({ payload }: MigrateUpArgs): Promise<void> {\n${\n upSQL\n ? `await payload.db.drizzle.execute(sql\\`\n\n${upSQL}\\`);\n`\n : '// Migration code'\n}\n};\n\nexport async function down({ payload }: MigrateDownArgs): Promise<void> {\n${\n downSQL\n ? `await payload.db.drizzle.execute(sql\\`\n\n${downSQL}\\`);\n`\n : '// Migration code'\n}\n};\n`\n\nconst getDefaultDrizzleSnapshot = (): DrizzleSnapshotJSON => ({\n id: '00000000-0000-0000-0000-000000000000',\n _meta: {\n columns: {},\n schemas: {},\n tables: {},\n },\n dialect: 'pg',\n enums: {},\n prevId: '00000000-0000-0000-0000-00000000000',\n schemas: {},\n tables: {},\n version: '5',\n})\n\nexport const createMigration: CreateMigration = async function createMigration(\n this: PostgresAdapter,\n { forceAcceptWarning, migrationName, payload },\n) {\n const dir = payload.db.migrationDir\n if (!fs.existsSync(dir)) {\n fs.mkdirSync(dir)\n }\n\n const { generateDrizzleJson, generateMigration } = require('drizzle-kit/payload')\n\n const [yyymmdd, hhmmss] = new Date().toISOString().split('T')\n const formattedDate = yyymmdd.replace(/\\D/g, '')\n const formattedTime = hhmmss.split('.')[0].replace(/\\D/g, '')\n\n const timestamp = `${formattedDate}_${formattedTime}`\n\n const fileName = migrationName\n ? `${timestamp}_${migrationName.replace(/\\W/g, '_')}`\n : `${timestamp}`\n\n const filePath = `${dir}/${fileName}`\n\n let drizzleJsonBefore = getDefaultDrizzleSnapshot()\n\n // Get latest migration snapshot\n const latestSnapshot = fs\n .readdirSync(dir)\n .filter((file) => file.endsWith('.json'))\n .sort()\n .reverse()?.[0]\n\n if (latestSnapshot) {\n const latestSnapshotJSON = JSON.parse(\n fs.readFileSync(`${dir}/${latestSnapshot}`, 'utf8'),\n ) as DrizzleSnapshotJSON\n\n drizzleJsonBefore = latestSnapshotJSON\n }\n\n const drizzleJsonAfter = generateDrizzleJson(this.schema)\n const sqlStatementsUp = await generateMigration(drizzleJsonBefore, drizzleJsonAfter)\n const sqlStatementsDown = await generateMigration(drizzleJsonAfter, drizzleJsonBefore)\n\n if (!sqlStatementsUp.length && !sqlStatementsDown.length && !forceAcceptWarning) {\n const { confirm: shouldCreateBlankMigration } = await prompts(\n {\n name: 'confirm',\n type: 'confirm',\n initial: false,\n message: 'No schema changes detected. Would you like to create a blank migration file?',\n },\n {\n onCancel: () => {\n process.exit(0)\n },\n },\n )\n\n if (!shouldCreateBlankMigration) {\n process.exit(0)\n }\n }\n\n // write schema\n fs.writeFileSync(`${filePath}.json`, JSON.stringify(drizzleJsonAfter, null, 2))\n\n // write migration\n fs.writeFileSync(\n `${filePath}.ts`,\n migrationTemplate(\n sqlStatementsUp.length ? sqlStatementsUp?.join('\\n') : undefined,\n sqlStatementsDown.length ? sqlStatementsDown?.join('\\n') : undefined,\n ),\n )\n payload.logger.info({ msg: `Migration created at ${filePath}.ts` })\n}\n"],"names":["fs","createRequire","prompts","require","url","migrationTemplate","upSQL","downSQL","getDefaultDrizzleSnapshot","id","_meta","columns","schemas","tables","dialect","enums","prevId","version","createMigration","forceAcceptWarning","migrationName","payload","dir","db","migrationDir","existsSync","mkdirSync","generateDrizzleJson","generateMigration","yyymmdd","hhmmss","Date","toISOString","split","formattedDate","replace","formattedTime","timestamp","fileName","filePath","drizzleJsonBefore","latestSnapshot","readdirSync","filter","file","endsWith","sort","reverse","latestSnapshotJSON","JSON","parse","readFileSync","drizzleJsonAfter","schema","sqlStatementsUp","sqlStatementsDown","length","confirm","shouldCreateBlankMigration","name","type","initial","message","onCancel","process","exit","writeFileSync","stringify","join","undefined","logger","info","msg"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,yDAAyD,GAIzD,OAAOA,QAAQ,KAAI;AACnB,SAASC,aAAa,QAAQ,SAAQ;AACtC,OAAOC,aAAa,UAAS;AAI7B,MAAMC,UAAUF,cAAc,YAAYG,GAAG;AAE7C,MAAMC,oBAAoB,CACxBC,OACAC,UACG,CAAC;;;AAGN,EACED,QACI,CAAC;;AAEP,EAAEA,MAAM;AACR,CAAC,GACK,oBACL;;;;AAID,EACEC,UACI,CAAC;;AAEP,EAAEA,QAAQ;AACV,CAAC,GACK,oBACL;;AAED,CAAC;AAED,MAAMC,4BAA4B,IAA4B,CAAA;QAC5DC,IAAI;QACJC,OAAO;YACLC,SAAS,CAAC;YACVC,SAAS,CAAC;YACVC,QAAQ,CAAC;QACX;QACAC,SAAS;QACTC,OAAO,CAAC;QACRC,QAAQ;QACRJ,SAAS,CAAC;QACVC,QAAQ,CAAC;QACTI,SAAS;IACX,CAAA;AAEA,OAAO,MAAMC,kBAAmC,eAAeA,gBAE7D,EAAEC,kBAAkB,EAAEC,aAAa,EAAEC,OAAO,EAAE;IAE9C,MAAMC,M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QAC/E,MAAM,EAAEsC,SAASC,0BAA0B,EAAE,GAAG,MAAMxD,QACpD;YACEyD,MAAM;YACNC,MAAM;YACNC,SAAS;YACTC,SAAS;QACX,GACA;YACEC,UAAU;gBACRC,QAAQC,IAAI,CAAC;YACf;QACF;QAGF,IAAI,CAACP,4BAA4B;YAC/BM,QAAQC,IAAI,CAAC;QACf;IACF;IAEA,eAAe;IACfjE,GAAGkE,aAAa,CAAC,CAAC,EAAE3B,SAAS,KAAK,CAAC,EAAEU,KAAKkB,SAAS,CAACf,kBAAkB,MAAM;IAE5E,kBAAkB;IAClBpD,GAAGkE,aAAa,CACd,CAAC,EAAE3B,SAAS,GAAG,CAAC,EAChBlC,kBACEiD,gBAAgBE,MAAM,GAAGF,iBAAiBc,KAAK,QAAQC,WACvDd,kBAAkBC,MAAM,GAAGD,mBAAmBa,KAAK,QAAQC;IAG/DhD,QAAQiD,MAAM,CAACC,IAAI,CAAC;QAAEC,KAAK,CAAC,qBAAqB,EAAEjC,SAAS,GAAG,CAAC;IAAC;AACnE,EAAC"}
|
package/dist/createVersion.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import type { CreateVersionArgs, TypeWithVersion } from 'payload/database';
|
2
|
-
import type { TypeWithID } from 'payload/types';
|
3
|
-
import type { PostgresAdapter } from './types.js';
|
4
|
-
export declare function createVersion<T extends TypeWithID>(this: PostgresAdapter, { autosave, collectionSlug, parent, req, versionData, }: CreateVersionArgs<T>): Promise<TypeWithVersion<T>>;
|
5
|
-
//# sourceMappingURL=createVersion.d.ts.map
|
@@ -1 +0,0 @@
|
|
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,EAA0B,UAAU,EAAE,MAAM,eAAe,CAAA;AAMvE,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,GAAkC,EAClC,WAAW,GACZ,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BA4CxB"}
|
package/dist/createVersion.js
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
2
|
-
import { buildVersionCollectionFields } from 'payload/versions';
|
3
|
-
import toSnakeCase from 'to-snake-case';
|
4
|
-
import { upsertRow } from './upsertRow/index.js';
|
5
|
-
export async function createVersion({ autosave, collectionSlug, parent, req = {}, versionData }) {
|
6
|
-
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
7
|
-
const collection = this.payload.collections[collectionSlug].config;
|
8
|
-
const defaultTableName = toSnakeCase(collection.slug);
|
9
|
-
const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`);
|
10
|
-
const version = {
|
11
|
-
...versionData
|
12
|
-
};
|
13
|
-
if (version.id) delete version.id;
|
14
|
-
const result = await upsertRow({
|
15
|
-
adapter: this,
|
16
|
-
data: {
|
17
|
-
autosave,
|
18
|
-
latest: true,
|
19
|
-
parent,
|
20
|
-
version
|
21
|
-
},
|
22
|
-
db,
|
23
|
-
fields: buildVersionCollectionFields(collection),
|
24
|
-
operation: 'create',
|
25
|
-
req,
|
26
|
-
tableName
|
27
|
-
});
|
28
|
-
const table = this.tables[tableName];
|
29
|
-
const relationshipsTable = this.tables[`_${defaultTableName}${this.versionsSuffix}${this.relationshipsSuffix}`];
|
30
|
-
if (collection.versions.drafts) {
|
31
|
-
await db.execute(sql`
|
32
|
-
UPDATE ${table}
|
33
|
-
SET latest = false
|
34
|
-
FROM ${relationshipsTable}
|
35
|
-
WHERE ${table.id} = ${relationshipsTable.parent}
|
36
|
-
AND ${relationshipsTable.path} = ${'parent'}
|
37
|
-
AND ${relationshipsTable[`${collectionSlug}ID`]} = ${parent}
|
38
|
-
AND ${table.id} != ${result.id};
|
39
|
-
`);
|
40
|
-
}
|
41
|
-
return result;
|
42
|
-
}
|
43
|
-
|
44
|
-
//# sourceMappingURL=createVersion.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/createVersion.ts"],"sourcesContent":["import type { CreateVersionArgs, TypeWithVersion } from 'payload/database'\nimport type { PayloadRequestWithData, 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 PayloadRequestWithData,\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 defaultTableName = toSnakeCase(collection.slug)\n\n const tableName = this.tableNameMap.get(`_${defaultTableName}${this.versionsSuffix}`)\n\n const version = { ...versionData }\n if (version.id) delete version.id\n\n const result = await upsertRow<TypeWithVersion<T>>({\n adapter: this,\n data: {\n autosave,\n latest: true,\n parent,\n version,\n },\n db,\n fields: buildVersionCollectionFields(collection),\n operation: 'create',\n req,\n tableName,\n })\n\n const table = this.tables[tableName]\n\n const relationshipsTable =\n this.tables[`_${defaultTableName}${this.versionsSuffix}${this.relationshipsSuffix}`]\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","defaultTableName","slug","tableName","tableNameMap","get","versionsSuffix","version","id","result","adapter","data","latest","fields","operation","table","tables","relationshipsTable","relationshipsSuffix","versions","drafts","execute","path"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,CAA2B,EAClCC,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,mBAAmBhB,YAAYY,WAAWK,IAAI;IAEpD,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEJ,iBAAiB,EAAE,IAAI,CAACK,cAAc,CAAC,CAAC;IAEpF,MAAMC,UAAU;QAAE,GAAGf,WAAW;IAAC;IACjC,IAAIe,QAAQC,EAAE,EAAE,OAAOD,QAAQC,EAAE;IAEjC,MAAMC,SAAS,MAAMvB,UAA8B;QACjDwB,SAAS,IAAI;QACbC,MAAM;YACJvB;YACAwB,QAAQ;YACRtB;YACAiB;QACF;QACAd;QACAoB,QAAQ7B,6BAA6Ba;QACrCiB,WAAW;QACXvB;QACAY;IACF;IAEA,MAAMY,QAAQ,IAAI,CAACC,MAAM,CAACb,UAAU;IAEpC,MAAMc,qBACJ,IAAI,CAACD,MAAM,CAAC,CAAC,CAAC,EAAEf,iBAAiB,EAAE,IAAI,CAACK,cAAc,CAAC,EAAE,IAAI,CAACY,mBAAmB,CAAC,CAAC,CAAC;IAEtF,IAAIrB,WAAWsB,QAAQ,CAACC,MAAM,EAAE;QAC9B,MAAM3B,GAAG4B,OAAO,CAACtC,GAAG,CAAC;aACZ,EAAEgC,MAAM;;WAEV,EAAEE,mBAAmB;YACpB,EAAEF,MAAMP,EAAE,CAAC,GAAG,EAAES,mBAAmB3B,MAAM,CAAC;YAC1C,EAAE2B,mBAAmBK,IAAI,CAAC,GAAG,EAAE,SAAS;YACxC,EAAEL,kBAAkB,CAAC,CAAC,EAAE5B,eAAe,EAAE,CAAC,CAAC,CAAC,GAAG,EAAEC,OAAO;YACxD,EAAEyB,MAAMP,EAAE,CAAC,IAAI,EAAEC,OAAOD,EAAE,CAAC;IACnC,CAAC;IACH;IAEA,OAAOC;AACT"}
|
package/dist/deleteMany.d.ts
DELETED
package/dist/deleteMany.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"deleteMany.d.ts","sourceRoot":"","sources":["../src/deleteMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAUlD,eAAO,MAAM,UAAU,EAAE,UA8BxB,CAAA"}
|
package/dist/deleteMany.js
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
import { inArray } from 'drizzle-orm';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { findMany } from './find/findMany.js';
|
4
|
-
export const deleteMany = async function deleteMany({ collection, req = {}, where }) {
|
5
|
-
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
6
|
-
const collectionConfig = this.payload.collections[collection].config;
|
7
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
|
8
|
-
const result = await findMany({
|
9
|
-
adapter: this,
|
10
|
-
fields: collectionConfig.fields,
|
11
|
-
limit: 0,
|
12
|
-
locale: req.locale,
|
13
|
-
page: 1,
|
14
|
-
pagination: false,
|
15
|
-
req,
|
16
|
-
tableName,
|
17
|
-
where
|
18
|
-
});
|
19
|
-
const ids = [];
|
20
|
-
result.docs.forEach((data)=>{
|
21
|
-
ids.push(data.id);
|
22
|
-
});
|
23
|
-
if (ids.length > 0) {
|
24
|
-
await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids));
|
25
|
-
}
|
26
|
-
};
|
27
|
-
|
28
|
-
//# sourceMappingURL=deleteMany.js.map
|
package/dist/deleteMany.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteMany.ts"],"sourcesContent":["import type { DeleteMany } from 'payload/database'\nimport type { PayloadRequestWithData } 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 PayloadRequestWithData, where },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\n const collectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\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","tableNameMap","get","slug","result","adapter","fields","limit","locale","page","pagination","ids","docs","forEach","data","push","id","length","delete","tables"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","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,CAA2B,EAAEC,KAAK,EAAE;IAEzD,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;IAEpE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAChB,YAAYU,iBAAiBO,IAAI;IAEzE,MAAMC,SAAS,MAAMjB,SAAS;QAC5BkB,SAAS,IAAI;QACbC,QAAQV,iBAAiBU,MAAM;QAC/BC,OAAO;QACPC,QAAQlB,IAAIkB,MAAM;QAClBC,MAAM;QACNC,YAAY;QACZpB;QACAU;QACAT;IACF;IAEA,MAAMoB,MAAM,EAAE;IAEdP,OAAOQ,IAAI,CAACC,OAAO,CAAC,CAACC;QACnBH,IAAII,IAAI,CAACD,KAAKE,EAAE;IAClB;IAEA,IAAIL,IAAIM,MAAM,GAAG,GAAG;QAClB,MAAMzB,GAAG0B,MAAM,CAAC,IAAI,CAACC,MAAM,CAACnB,UAAU,EAAET,KAAK,CAACN,QAAQ,IAAI,CAACkC,MAAM,CAACnB,UAAU,CAACgB,EAAE,EAAEL;IACnF;AACF,EAAC"}
|
package/dist/deleteOne.d.ts
DELETED
package/dist/deleteOne.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
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,SAwDvB,CAAA"}
|
package/dist/deleteOne.js
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
import { eq } from 'drizzle-orm';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { buildFindManyArgs } from './find/buildFindManyArgs.js';
|
4
|
-
import buildQuery from './queries/buildQuery.js';
|
5
|
-
import { selectDistinct } from './queries/selectDistinct.js';
|
6
|
-
import { transform } from './transform/read/index.js';
|
7
|
-
export const deleteOne = async function deleteOne({ collection: collectionSlug, req = {}, where: whereArg }) {
|
8
|
-
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
9
|
-
const collection = this.payload.collections[collectionSlug].config;
|
10
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
11
|
-
let docToDelete;
|
12
|
-
const { joinAliases, joins, selectFields, where } = await buildQuery({
|
13
|
-
adapter: this,
|
14
|
-
fields: collection.fields,
|
15
|
-
locale: req.locale,
|
16
|
-
tableName,
|
17
|
-
where: whereArg
|
18
|
-
});
|
19
|
-
const selectDistinctResult = await selectDistinct({
|
20
|
-
adapter: this,
|
21
|
-
chainedMethods: [
|
22
|
-
{
|
23
|
-
args: [
|
24
|
-
1
|
25
|
-
],
|
26
|
-
method: 'limit'
|
27
|
-
}
|
28
|
-
],
|
29
|
-
db,
|
30
|
-
joinAliases,
|
31
|
-
joins,
|
32
|
-
selectFields,
|
33
|
-
tableName,
|
34
|
-
where
|
35
|
-
});
|
36
|
-
if (selectDistinctResult?.[0]?.id) {
|
37
|
-
docToDelete = await db.query[tableName].findFirst({
|
38
|
-
where: eq(this.tables[tableName].id, selectDistinctResult[0].id)
|
39
|
-
});
|
40
|
-
} else {
|
41
|
-
const findManyArgs = buildFindManyArgs({
|
42
|
-
adapter: this,
|
43
|
-
depth: 0,
|
44
|
-
fields: collection.fields,
|
45
|
-
tableName
|
46
|
-
});
|
47
|
-
findManyArgs.where = where;
|
48
|
-
docToDelete = await db.query[tableName].findFirst(findManyArgs);
|
49
|
-
}
|
50
|
-
const result = transform({
|
51
|
-
config: this.payload.config,
|
52
|
-
data: docToDelete,
|
53
|
-
fields: collection.fields
|
54
|
-
});
|
55
|
-
await db.delete(this.tables[tableName]).where(eq(this.tables[tableName].id, docToDelete.id));
|
56
|
-
return result;
|
57
|
-
};
|
58
|
-
|
59
|
-
//# sourceMappingURL=deleteOne.js.map
|
package/dist/deleteOne.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteOne.ts"],"sourcesContent":["import type { DeleteOne } from 'payload/database'\nimport type { PayloadRequestWithData } 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 PayloadRequestWithData, where: whereArg },\n) {\n const db = this.sessions[req.transactionID]?.db || this.drizzle\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 { 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","tableNameMap","get","slug","docToDelete","joinAliases","joins","selectFields","adapter","fields","locale","selectDistinctResult","chainedMethods","args","method","id","query","findFirst","tables","findManyArgs","depth","result","data","delete"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,CAA2B,EAAEC,OAAOC,QAAQ,EAAE;IAEnF,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;IAElE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACpB,YAAYM,WAAWe,IAAI;IAEnE,IAAIC;IAEJ,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,YAAY,EAAEhB,KAAK,EAAE,GAAG,MAAMP,WAAW;QACnEwB,SAAS,IAAI;QACbC,QAAQrB,WAAWqB,MAAM;QACzBC,QAAQpB,IAAIoB,MAAM;QAClBV;QACAT,OAAOC;IACT;IAEA,MAAMmB,uBAAuB,MAAM1B,eAAe;QAChDuB,SAAS,IAAI;QACbI,gBAAgB;YAAC;gBAAEC,MAAM;oBAAC;iBAAE;gBAAEC,QAAQ;YAAQ;SAAE;QAChDrB;QACAY;QACAC;QACAC;QACAP;QACAT;IACF;IAEA,IAAIoB,sBAAsB,CAAC,EAAE,EAAEI,IAAI;QACjCX,cAAc,MAAMX,GAAGuB,KAAK,CAAChB,UAAU,CAACiB,SAAS,CAAC;YAChD1B,OAAOV,GAAG,IAAI,CAACqC,MAAM,CAAClB,UAAU,CAACe,EAAE,EAAEJ,oBAAoB,CAAC,EAAE,CAACI,EAAE;QACjE;IACF,OAAO;QACL,MAAMI,eAAepC,kBAAkB;YACrCyB,SAAS,IAAI;YACbY,OAAO;YACPX,QAAQrB,WAAWqB,MAAM;YACzBT;QACF;QAEAmB,aAAa5B,KAAK,GAAGA;QAErBa,cAAc,MAAMX,GAAGuB,KAAK,CAAChB,UAAU,CAACiB,SAAS,CAACE;IACpD;IAEA,MAAME,SAASnC,UAAU;QACvBa,QAAQ,IAAI,CAACF,OAAO,CAACE,MAAM;QAC3BuB,MAAMlB;QACNK,QAAQrB,WAAWqB,MAAM;IAC3B;IAEA,MAAMhB,GAAG8B,MAAM,CAAC,IAAI,CAACL,MAAM,CAAClB,UAAU,EAAET,KAAK,CAACV,GAAG,IAAI,CAACqC,MAAM,CAAClB,UAAU,CAACe,EAAE,EAAEX,YAAYW,EAAE;IAE1F,OAAOM;AACT,EAAC"}
|
package/dist/deleteVersions.d.ts
DELETED
@@ -1 +0,0 @@
|
|
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,cAoC5B,CAAA"}
|
package/dist/deleteVersions.js
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import { inArray } from 'drizzle-orm';
|
2
|
-
import { buildVersionCollectionFields } from 'payload/versions';
|
3
|
-
import toSnakeCase from 'to-snake-case';
|
4
|
-
import { findMany } from './find/findMany.js';
|
5
|
-
export const deleteVersions = async function deleteVersion({ collection, locale, req = {}, where: where }) {
|
6
|
-
const db = this.sessions[req.transactionID]?.db || this.drizzle;
|
7
|
-
const collectionConfig = this.payload.collections[collection].config;
|
8
|
-
const tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
|
9
|
-
const fields = buildVersionCollectionFields(collectionConfig);
|
10
|
-
const { docs } = await findMany({
|
11
|
-
adapter: this,
|
12
|
-
fields,
|
13
|
-
limit: 0,
|
14
|
-
locale,
|
15
|
-
page: 1,
|
16
|
-
pagination: false,
|
17
|
-
req,
|
18
|
-
tableName,
|
19
|
-
where
|
20
|
-
});
|
21
|
-
const ids = [];
|
22
|
-
docs.forEach((doc)=>{
|
23
|
-
ids.push(doc.id);
|
24
|
-
});
|
25
|
-
if (ids.length > 0) {
|
26
|
-
await db.delete(this.tables[tableName]).where(inArray(this.tables[tableName].id, ids));
|
27
|
-
}
|
28
|
-
return docs;
|
29
|
-
};
|
30
|
-
|
31
|
-
//# sourceMappingURL=deleteVersions.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/deleteVersions.ts"],"sourcesContent":["import type { DeleteVersions } from 'payload/database'\nimport type { PayloadRequestWithData, 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 PayloadRequestWithData, 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 = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\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","toSnakeCase","findMany","deleteVersions","deleteVersion","collection","locale","req","where","db","sessions","transactionID","drizzle","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","versionsSuffix","fields","docs","adapter","limit","page","pagination","ids","forEach","doc","push","id","length","delete","tables"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,CAA2B,EAAEC,OAAOA,KAAK,EAAE;IAExE,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,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAElB,YAAYY,iBAAiBO,IAAI,EAAE,EAAE,IAAI,CAACC,cAAc,CAAC,CAAC;IAGhE,MAAMC,SAAStB,6BAA6Ba;IAE5C,MAAM,EAAEU,IAAI,EAAE,GAAG,MAAMrB,SAAS;QAC9BsB,SAAS,IAAI;QACbF;QACAG,OAAO;QACPnB;QACAoB,MAAM;QACNC,YAAY;QACZpB;QACAU;QACAT;IACF;IAEA,MAAMoB,MAAM,EAAE;IAEdL,KAAKM,OAAO,CAAC,CAACC;QACZF,IAAIG,IAAI,CAACD,IAAIE,EAAE;IACjB;IAEA,IAAIJ,IAAIK,MAAM,GAAG,GAAG;QAClB,MAAMxB,GAAGyB,MAAM,CAAC,IAAI,CAACC,MAAM,CAAClB,UAAU,EAAET,KAAK,CAACT,QAAQ,IAAI,CAACoC,MAAM,CAAClB,UAAU,CAACe,EAAE,EAAEJ;IACnF;IAEA,OAAOL;AACT,EAAC"}
|
package/dist/destroy.d.ts
DELETED
package/dist/destroy.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAK/C,eAAO,MAAM,OAAO,EAAE,OAOrB,CAAA"}
|
package/dist/destroy.js
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
2
|
-
export const destroy = async function destroy() {
|
3
|
-
this.enums = {};
|
4
|
-
this.schema = {};
|
5
|
-
this.tables = {};
|
6
|
-
this.relations = {};
|
7
|
-
this.fieldConstraints = {};
|
8
|
-
this.drizzle = undefined;
|
9
|
-
};
|
10
|
-
|
11
|
-
//# sourceMappingURL=destroy.js.map
|
package/dist/destroy.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport const destroy: Destroy = async function destroy(this: PostgresAdapter) {\n this.enums = {}\n this.schema = {}\n this.tables = {}\n this.relations = {}\n this.fieldConstraints = {}\n this.drizzle = undefined\n}\n"],"names":["destroy","enums","schema","tables","relations","fieldConstraints","drizzle","undefined"],"rangeMappings":";;;;;;;;","mappings":"AAIA,4DAA4D;AAC5D,OAAO,MAAMA,UAAmB,eAAeA;IAC7C,IAAI,CAACC,KAAK,GAAG,CAAC;IACd,IAAI,CAACC,MAAM,GAAG,CAAC;IACf,IAAI,CAACC,MAAM,GAAG,CAAC;IACf,IAAI,CAACC,SAAS,GAAG,CAAC;IAClB,IAAI,CAACC,gBAAgB,GAAG,CAAC;IACzB,IAAI,CAACC,OAAO,GAAGC;AACjB,EAAC"}
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import type { DBQueryConfig } from 'drizzle-orm';
|
2
|
-
import type { Field } from 'payload/types';
|
3
|
-
import type { PostgresAdapter } from '../types.js';
|
4
|
-
type BuildFindQueryArgs = {
|
5
|
-
adapter: PostgresAdapter;
|
6
|
-
depth: number;
|
7
|
-
fields: Field[];
|
8
|
-
tableName: string;
|
9
|
-
};
|
10
|
-
export type Result = DBQueryConfig<'many', true, any, any>;
|
11
|
-
export declare const buildFindManyArgs: ({ adapter, depth, fields, tableName, }: BuildFindQueryArgs) => Record<string, unknown>;
|
12
|
-
export {};
|
13
|
-
//# sourceMappingURL=buildFindManyArgs.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"buildFindManyArgs.d.ts","sourceRoot":"","sources":["../../src/find/buildFindManyArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAIlD,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;AAI1D,eAAO,MAAM,iBAAiB,2CAK3B,kBAAkB,KAAG,OAAO,MAAM,EAAE,OAAO,CA2D7C,CAAA"}
|
@@ -1,64 +0,0 @@
|
|
1
|
-
import { traverseFields } from './traverseFields.js';
|
2
|
-
// Generate the Drizzle query for findMany based on
|
3
|
-
// a collection field structure
|
4
|
-
export const buildFindManyArgs = ({ adapter, depth, fields, tableName })=>{
|
5
|
-
const result = {
|
6
|
-
with: {}
|
7
|
-
};
|
8
|
-
const _locales = {
|
9
|
-
columns: {
|
10
|
-
id: false,
|
11
|
-
_parentID: false
|
12
|
-
}
|
13
|
-
};
|
14
|
-
if (adapter.tables[`${tableName}_texts`]) {
|
15
|
-
result.with._texts = {
|
16
|
-
columns: {
|
17
|
-
id: false,
|
18
|
-
parent: false
|
19
|
-
},
|
20
|
-
orderBy: ({ order }, { asc: ASC })=>[
|
21
|
-
ASC(order)
|
22
|
-
]
|
23
|
-
};
|
24
|
-
}
|
25
|
-
if (adapter.tables[`${tableName}_numbers`]) {
|
26
|
-
result.with._numbers = {
|
27
|
-
columns: {
|
28
|
-
id: false,
|
29
|
-
parent: false
|
30
|
-
},
|
31
|
-
orderBy: ({ order }, { asc: ASC })=>[
|
32
|
-
ASC(order)
|
33
|
-
]
|
34
|
-
};
|
35
|
-
}
|
36
|
-
if (adapter.tables[`${tableName}${adapter.relationshipsSuffix}`]) {
|
37
|
-
result.with._rels = {
|
38
|
-
columns: {
|
39
|
-
id: false,
|
40
|
-
parent: false
|
41
|
-
},
|
42
|
-
orderBy: ({ order }, { asc: ASC })=>[
|
43
|
-
ASC(order)
|
44
|
-
]
|
45
|
-
};
|
46
|
-
}
|
47
|
-
if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {
|
48
|
-
result.with._locales = _locales;
|
49
|
-
}
|
50
|
-
traverseFields({
|
51
|
-
_locales,
|
52
|
-
adapter,
|
53
|
-
currentArgs: result,
|
54
|
-
currentTableName: tableName,
|
55
|
-
depth,
|
56
|
-
fields,
|
57
|
-
path: '',
|
58
|
-
topLevelArgs: result,
|
59
|
-
topLevelTableName: tableName
|
60
|
-
});
|
61
|
-
return result;
|
62
|
-
};
|
63
|
-
|
64
|
-
//# sourceMappingURL=buildFindManyArgs.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/find/buildFindManyArgs.ts"],"sourcesContent":["import type { DBQueryConfig } from 'drizzle-orm'\nimport type { Field } from 'payload/types'\n\nimport type { PostgresAdapter } from '../types.js'\n\nimport { traverseFields } from './traverseFields.js'\n\ntype BuildFindQueryArgs = {\n adapter: PostgresAdapter\n depth: number\n fields: Field[]\n tableName: string\n}\n\nexport type Result = DBQueryConfig<'many', true, any, any>\n\n// Generate the Drizzle query for findMany based on\n// a collection field structure\nexport const buildFindManyArgs = ({\n adapter,\n depth,\n fields,\n tableName,\n}: BuildFindQueryArgs): Record<string, unknown> => {\n const result: Result = {\n with: {},\n }\n\n const _locales: Result = {\n columns: {\n id: false,\n _parentID: false,\n },\n }\n\n if (adapter.tables[`${tableName}_texts`]) {\n result.with._texts = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}_numbers`]) {\n result.with._numbers = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}${adapter.relationshipsSuffix}`]) {\n result.with._rels = {\n columns: {\n id: false,\n parent: false,\n },\n orderBy: ({ order }, { asc: ASC }) => [ASC(order)],\n }\n }\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n result.with._locales = _locales\n }\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: result,\n currentTableName: tableName,\n depth,\n fields,\n path: '',\n topLevelArgs: result,\n topLevelTableName: tableName,\n })\n\n return result\n}\n"],"names":["traverseFields","buildFindManyArgs","adapter","depth","fields","tableName","result","with","_locales","columns","id","_parentID","tables","_texts","parent","orderBy","order","asc","ASC","_numbers","relationshipsSuffix","_rels","localesSuffix","currentArgs","currentTableName","path","topLevelArgs","topLevelTableName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,IAAI,CAACC,QAAQ,GAAGA;IACzB;IAEAR,eAAe;QACbQ;QACAN;QACAqB,aAAajB;QACbkB,kBAAkBnB;QAClBF;QACAC;QACAqB,MAAM;QACNC,cAAcpB;QACdqB,mBAAmBtB;IACrB;IAEA,OAAOC;AACT,EAAC"}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { QueryPromise } from 'drizzle-orm';
|
2
|
-
export type ChainedMethods = {
|
3
|
-
args: unknown[];
|
4
|
-
method: string;
|
5
|
-
}[];
|
6
|
-
/**
|
7
|
-
* Call and returning methods that would normally be chained together but cannot be because of control logic
|
8
|
-
* @param methods
|
9
|
-
* @param query
|
10
|
-
*/
|
11
|
-
declare const chainMethods: <T>({ methods, query }: {
|
12
|
-
methods: any;
|
13
|
-
query: any;
|
14
|
-
}) => QueryPromise<T>;
|
15
|
-
export { chainMethods };
|
16
|
-
//# sourceMappingURL=chainMethods.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"chainMethods.d.ts","sourceRoot":"","sources":["../../src/find/chainMethods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;CACf,EAAE,CAAA;AAEH;;;;GAIG;AACH,QAAA,MAAM,YAAY;;;MAA4B,aAAa,CAAC,CAI3D,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Call and returning methods that would normally be chained together but cannot be because of control logic
|
3
|
-
* @param methods
|
4
|
-
* @param query
|
5
|
-
*/ const chainMethods = ({ methods, query })=>{
|
6
|
-
return methods.reduce((query, { args, method })=>{
|
7
|
-
return query[method](...args);
|
8
|
-
}, query);
|
9
|
-
};
|
10
|
-
export { chainMethods };
|
11
|
-
|
12
|
-
//# sourceMappingURL=chainMethods.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/find/chainMethods.ts"],"sourcesContent":["import type { QueryPromise } from 'drizzle-orm'\n\nexport type ChainedMethods = {\n args: unknown[]\n method: string\n}[]\n\n/**\n * Call and returning methods that would normally be chained together but cannot be because of control logic\n * @param methods\n * @param query\n */\nconst chainMethods = <T>({ methods, query }): QueryPromise<T> => {\n return methods.reduce((query, { args, method }) => {\n return query[method](...args)\n }, query)\n}\n\nexport { chainMethods }\n"],"names":["chainMethods","methods","query","reduce","args","method"],"rangeMappings":";;;;;;;;;","mappings":"AAOA;;;;CAIC,GACD,MAAMA,eAAe,CAAI,EAAEC,OAAO,EAAEC,KAAK,EAAE;IACzC,OAAOD,QAAQE,MAAM,CAAC,CAACD,OAAO,EAAEE,IAAI,EAAEC,MAAM,EAAE;QAC5C,OAAOH,KAAK,CAACG,OAAO,IAAID;IAC1B,GAAGF;AACL;AAEA,SAASF,YAAY,GAAE"}
|
package/dist/find/findMany.d.ts
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import type { FindArgs } from 'payload/database';
|
2
|
-
import type { Field } from 'payload/types';
|
3
|
-
import type { PostgresAdapter } from '../types.js';
|
4
|
-
type Args = Omit<FindArgs, 'collection'> & {
|
5
|
-
adapter: PostgresAdapter;
|
6
|
-
fields: Field[];
|
7
|
-
tableName: string;
|
8
|
-
};
|
9
|
-
export declare const findMany: ({ adapter, fields, limit: limitArg, locale, page, pagination, req, skip, sort, tableName, where: whereArg, }: Args) => Promise<{
|
10
|
-
docs: any;
|
11
|
-
hasNextPage: boolean;
|
12
|
-
hasPrevPage: boolean;
|
13
|
-
limit: number;
|
14
|
-
nextPage: number;
|
15
|
-
page: number;
|
16
|
-
pagingCounter: number;
|
17
|
-
prevPage: number;
|
18
|
-
totalDocs: number;
|
19
|
-
totalPages: number;
|
20
|
-
}>;
|
21
|
-
export {};
|
22
|
-
//# sourceMappingURL=findMany.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"findMany.d.ts","sourceRoot":"","sources":["../../src/find/findMany.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,KAAK,EAAE,KAAK,EAAsC,MAAM,eAAe,CAAA;AAI9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AASlD,KAAK,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,eAAO,MAAM,QAAQ,iHAYlB,IAAI;;;;;;;;;;;EAgKN,CAAA"}
|
package/dist/find/findMany.js
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
import { inArray, sql } from 'drizzle-orm';
|
2
|
-
import buildQuery from '../queries/buildQuery.js';
|
3
|
-
import { selectDistinct } from '../queries/selectDistinct.js';
|
4
|
-
import { transform } from '../transform/read/index.js';
|
5
|
-
import { buildFindManyArgs } from './buildFindManyArgs.js';
|
6
|
-
import { chainMethods } from './chainMethods.js';
|
7
|
-
export const findMany = async function find({ adapter, fields, limit: limitArg, locale, page = 1, pagination, req = {}, skip, sort, tableName, where: whereArg }) {
|
8
|
-
const db = adapter.sessions[req.transactionID]?.db || adapter.drizzle;
|
9
|
-
const table = adapter.tables[tableName];
|
10
|
-
const limit = limitArg ?? 10;
|
11
|
-
let totalDocs;
|
12
|
-
let totalPages;
|
13
|
-
let hasPrevPage;
|
14
|
-
let hasNextPage;
|
15
|
-
let pagingCounter;
|
16
|
-
const { joinAliases, joins, orderBy, selectFields, where } = await buildQuery({
|
17
|
-
adapter,
|
18
|
-
fields,
|
19
|
-
locale,
|
20
|
-
sort,
|
21
|
-
tableName,
|
22
|
-
where: whereArg
|
23
|
-
});
|
24
|
-
const orderedIDMap = {};
|
25
|
-
let orderedIDs;
|
26
|
-
const selectDistinctMethods = [];
|
27
|
-
if (orderBy?.order && orderBy?.column) {
|
28
|
-
selectDistinctMethods.push({
|
29
|
-
args: [
|
30
|
-
orderBy.order(orderBy.column)
|
31
|
-
],
|
32
|
-
method: 'orderBy'
|
33
|
-
});
|
34
|
-
}
|
35
|
-
const findManyArgs = buildFindManyArgs({
|
36
|
-
adapter,
|
37
|
-
depth: 0,
|
38
|
-
fields,
|
39
|
-
tableName
|
40
|
-
});
|
41
|
-
selectDistinctMethods.push({
|
42
|
-
args: [
|
43
|
-
skip || (page - 1) * limit
|
44
|
-
],
|
45
|
-
method: 'offset'
|
46
|
-
});
|
47
|
-
selectDistinctMethods.push({
|
48
|
-
args: [
|
49
|
-
limit === 0 ? undefined : limit
|
50
|
-
],
|
51
|
-
method: 'limit'
|
52
|
-
});
|
53
|
-
const selectDistinctResult = await selectDistinct({
|
54
|
-
adapter,
|
55
|
-
chainedMethods: selectDistinctMethods,
|
56
|
-
db,
|
57
|
-
joinAliases,
|
58
|
-
joins,
|
59
|
-
selectFields,
|
60
|
-
tableName,
|
61
|
-
where
|
62
|
-
});
|
63
|
-
if (selectDistinctResult) {
|
64
|
-
if (selectDistinctResult.length === 0) {
|
65
|
-
return {
|
66
|
-
docs: [],
|
67
|
-
hasNextPage: false,
|
68
|
-
hasPrevPage: false,
|
69
|
-
limit,
|
70
|
-
nextPage: null,
|
71
|
-
page: 1,
|
72
|
-
pagingCounter: 0,
|
73
|
-
prevPage: null,
|
74
|
-
totalDocs: 0,
|
75
|
-
totalPages: 0
|
76
|
-
};
|
77
|
-
} else {
|
78
|
-
// set the id in an object for sorting later
|
79
|
-
selectDistinctResult.forEach(({ id }, i)=>{
|
80
|
-
orderedIDMap[id] = i;
|
81
|
-
});
|
82
|
-
orderedIDs = Object.keys(orderedIDMap);
|
83
|
-
findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs);
|
84
|
-
}
|
85
|
-
} else {
|
86
|
-
findManyArgs.limit = limitArg === 0 ? undefined : limitArg;
|
87
|
-
const offset = skip || (page - 1) * limitArg;
|
88
|
-
if (!Number.isNaN(offset)) findManyArgs.offset = offset;
|
89
|
-
if (where) {
|
90
|
-
findManyArgs.where = where;
|
91
|
-
}
|
92
|
-
findManyArgs.orderBy = orderBy.order(orderBy.column);
|
93
|
-
}
|
94
|
-
const findPromise = db.query[tableName].findMany(findManyArgs);
|
95
|
-
if (pagination !== false && (orderedIDs ? orderedIDs?.length <= limit : true)) {
|
96
|
-
const selectCountMethods = [];
|
97
|
-
joinAliases.forEach(({ condition, table })=>{
|
98
|
-
selectCountMethods.push({
|
99
|
-
args: [
|
100
|
-
table,
|
101
|
-
condition
|
102
|
-
],
|
103
|
-
method: 'leftJoin'
|
104
|
-
});
|
105
|
-
});
|
106
|
-
Object.entries(joins).forEach(([joinTable, condition])=>{
|
107
|
-
if (joinTable) {
|
108
|
-
selectCountMethods.push({
|
109
|
-
args: [
|
110
|
-
adapter.tables[joinTable],
|
111
|
-
condition
|
112
|
-
],
|
113
|
-
method: 'leftJoin'
|
114
|
-
});
|
115
|
-
}
|
116
|
-
});
|
117
|
-
const countResult = await chainMethods({
|
118
|
-
methods: selectCountMethods,
|
119
|
-
query: db.select({
|
120
|
-
count: sql`count
|
121
|
-
(DISTINCT ${adapter.tables[tableName].id})`
|
122
|
-
}).from(table).where(where)
|
123
|
-
});
|
124
|
-
totalDocs = Number(countResult[0].count);
|
125
|
-
totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1;
|
126
|
-
hasPrevPage = page > 1;
|
127
|
-
hasNextPage = totalPages > page;
|
128
|
-
pagingCounter = (page - 1) * limit + 1;
|
129
|
-
}
|
130
|
-
const rawDocs = await findPromise;
|
131
|
-
// sort rawDocs from selectQuery
|
132
|
-
if (Object.keys(orderedIDMap).length > 0) {
|
133
|
-
rawDocs.sort((a, b)=>orderedIDMap[a.id] - orderedIDMap[b.id]);
|
134
|
-
}
|
135
|
-
if (pagination === false || !totalDocs) {
|
136
|
-
totalDocs = rawDocs.length;
|
137
|
-
totalPages = 1;
|
138
|
-
pagingCounter = 1;
|
139
|
-
hasPrevPage = false;
|
140
|
-
hasNextPage = false;
|
141
|
-
}
|
142
|
-
const docs = rawDocs.map((data)=>{
|
143
|
-
return transform({
|
144
|
-
config: adapter.payload.config,
|
145
|
-
data,
|
146
|
-
fields
|
147
|
-
});
|
148
|
-
});
|
149
|
-
return {
|
150
|
-
docs,
|
151
|
-
hasNextPage,
|
152
|
-
hasPrevPage,
|
153
|
-
limit,
|
154
|
-
nextPage: hasNextPage ? page + 1 : null,
|
155
|
-
page,
|
156
|
-
pagingCounter,
|
157
|
-
prevPage: hasPrevPage ? page - 1 : null,
|
158
|
-
totalDocs,
|
159
|
-
totalPages
|
160
|
-
};
|
161
|
-
};
|
162
|
-
|
163
|
-
//# sourceMappingURL=findMany.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../../src/find/findMany.ts"],"sourcesContent":["import type { FindArgs } from 'payload/database'\nimport type { Field, PayloadRequestWithData, TypeWithID } from 'payload/types'\n\nimport { inArray, sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { ChainedMethods } from './chainMethods.js'\n\nimport buildQuery from '../queries/buildQuery.js'\nimport { selectDistinct } from '../queries/selectDistinct.js'\nimport { transform } from '../transform/read/index.js'\nimport { buildFindManyArgs } from './buildFindManyArgs.js'\nimport { chainMethods } from './chainMethods.js'\n\ntype Args = Omit<FindArgs, 'collection'> & {\n adapter: PostgresAdapter\n fields: Field[]\n tableName: string\n}\n\nexport const findMany = async function find({\n adapter,\n fields,\n limit: limitArg,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequestWithData,\n skip,\n sort,\n tableName,\n where: whereArg,\n}: Args) {\n const db = adapter.sessions[req.transactionID]?.db || adapter.drizzle\n const table = adapter.tables[tableName]\n\n const limit = limitArg ?? 10\n let totalDocs: number\n let totalPages: number\n let hasPrevPage: boolean\n let hasNextPage: boolean\n let pagingCounter: number\n\n const { joinAliases, joins, orderBy, selectFields, where } = await buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: whereArg,\n })\n\n const orderedIDMap: Record<number | string, number> = {}\n let orderedIDs: (number | string)[]\n\n const selectDistinctMethods: ChainedMethods = []\n\n if (orderBy?.order && orderBy?.column) {\n selectDistinctMethods.push({\n args: [orderBy.order(orderBy.column)],\n method: 'orderBy',\n })\n }\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n tableName,\n })\n\n selectDistinctMethods.push({ args: [skip || (page - 1) * limit], method: 'offset' })\n selectDistinctMethods.push({ args: [limit === 0 ? undefined : limit], method: 'limit' })\n\n const selectDistinctResult = await selectDistinct({\n adapter,\n chainedMethods: selectDistinctMethods,\n db,\n joinAliases,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult) {\n if (selectDistinctResult.length === 0) {\n return {\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n } else {\n // set the id in an object for sorting later\n selectDistinctResult.forEach(({ id }, i) => {\n orderedIDMap[id] = i\n })\n orderedIDs = Object.keys(orderedIDMap)\n findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs)\n }\n } else {\n findManyArgs.limit = limitArg === 0 ? undefined : limitArg\n\n const offset = skip || (page - 1) * limitArg\n\n if (!Number.isNaN(offset)) findManyArgs.offset = offset\n\n if (where) {\n findManyArgs.where = where\n }\n findManyArgs.orderBy = orderBy.order(orderBy.column)\n }\n\n const findPromise = db.query[tableName].findMany(findManyArgs)\n\n if (pagination !== false && (orderedIDs ? orderedIDs?.length <= limit : true)) {\n const selectCountMethods: ChainedMethods = []\n\n joinAliases.forEach(({ condition, table }) => {\n selectCountMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectCountMethods.push({\n args: [adapter.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${adapter.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n totalDocs = Number(countResult[0].count)\n totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1\n hasPrevPage = page > 1\n hasNextPage = totalPages > page\n pagingCounter = (page - 1) * limit + 1\n }\n\n const rawDocs = await findPromise\n // sort rawDocs from selectQuery\n if (Object.keys(orderedIDMap).length > 0) {\n rawDocs.sort((a, b) => orderedIDMap[a.id] - orderedIDMap[b.id])\n }\n\n if (pagination === false || !totalDocs) {\n totalDocs = rawDocs.length\n totalPages = 1\n pagingCounter = 1\n hasPrevPage = false\n hasNextPage = false\n }\n\n const docs = rawDocs.map((data: TypeWithID) => {\n return transform({\n config: adapter.payload.config,\n data,\n fields,\n })\n })\n\n return {\n docs,\n hasNextPage,\n hasPrevPage,\n limit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter,\n prevPage: hasPrevPage ? page - 1 : null,\n totalDocs,\n totalPages,\n }\n}\n"],"names":["inArray","sql","buildQuery","selectDistinct","transform","buildFindManyArgs","chainMethods","findMany","find","adapter","fields","limit","limitArg","locale","page","pagination","req","skip","sort","tableName","where","whereArg","db","sessions","transactionID","drizzle","table","tables","totalDocs","totalPages","hasPrevPage","hasNextPage","pagingCounter","joinAliases","joins","orderBy","selectFields","orderedIDMap","orderedIDs","selectDistinctMethods","order","column","push","args","method","findManyArgs","depth","undefined","selectDistinctResult","chainedMethods","length","docs","nextPage","prevPage","forEach","id","i","Object","keys","offset","Number","isNaN","findPromise","query","selectCountMethods","condition","entries","joinTable","countResult","methods","select","count","from","Math","ceil","rawDocs","a","b","map","data","config","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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