@payloadcms/db-postgres 3.0.0-canary.ee6d727 → 3.0.0-canary.f118ee4
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 +10 -6
- package/dist/connect.js.map +1 -1
- package/dist/exports/migration-utils.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -67
- package/dist/index.js.map +1 -1
- package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +5 -5
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -2
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +1 -1
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.d.ts +2 -3
- package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/index.js +7 -7
- package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +5 -4
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +4 -4
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js +1 -1
- package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
- package/dist/predefinedMigrations/v2-v3/types.js.map +1 -1
- package/dist/types.d.ts +42 -80
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +20 -17
- package/dist/count.d.ts +0 -3
- package/dist/count.d.ts.map +0 -1
- package/dist/count.js +0 -41
- 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 -102
- 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 -40
- 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 -15
- package/dist/destroy.js.map +0 -1
- package/dist/find/buildFindManyArgs.d.ts +0 -17
- package/dist/find/buildFindManyArgs.d.ts.map +0 -1
- package/dist/find/buildFindManyArgs.js +0 -65
- 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 -152
- package/dist/find/findMany.js.map +0 -1
- package/dist/find/traverseFields.d.ts +0 -17
- package/dist/find/traverseFields.d.ts.map +0 -1
- package/dist/find/traverseFields.js +0 -156
- 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 -91
- 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 -16
- package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
- package/dist/queries/buildAndOrConditions.js +0 -28
- package/dist/queries/buildAndOrConditions.js.map +0 -1
- package/dist/queries/buildQuery.d.ts +0 -30
- package/dist/queries/buildQuery.d.ts.map +0 -1
- package/dist/queries/buildQuery.js +0 -72
- 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 -50
- package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
- package/dist/queries/getTableColumnFromPath.js +0 -517
- 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 -16
- package/dist/queries/parseParams.d.ts.map +0 -1
- package/dist/queries/parseParams.js +0 -183
- 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 -22
- package/dist/queries/selectDistinct.d.ts.map +0 -1
- package/dist/queries/selectDistinct.js +0 -30
- 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 -34
- package/dist/schema/build.d.ts.map +0 -1
- package/dist/schema/build.js +0 -369
- 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 -36
- package/dist/schema/traverseFields.d.ts.map +0 -1
- package/dist/schema/traverseFields.js +0 -614
- 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 -51
- 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 -14
- package/dist/transform/read/index.d.ts.map +0 -1
- package/dist/transform/read/index.js +0 -44
- 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 -60
- package/dist/transform/read/relationship.js.map +0 -1
- package/dist/transform/read/traverseFields.d.ts +0 -57
- package/dist/transform/read/traverseFields.d.ts.map +0 -1
- package/dist/transform/read/traverseFields.js +0 -435
- 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 -445
- 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 -54
- 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 -279
- 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 -32
- 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,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;;;;;;;;;;;EAsJN,CAAA"}
|
package/dist/find/findMany.js
DELETED
@@ -1,152 +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 { 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
|
-
joins,
|
58
|
-
selectFields,
|
59
|
-
tableName,
|
60
|
-
where
|
61
|
-
});
|
62
|
-
if (selectDistinctResult) {
|
63
|
-
if (selectDistinctResult.length === 0) {
|
64
|
-
return {
|
65
|
-
docs: [],
|
66
|
-
hasNextPage: false,
|
67
|
-
hasPrevPage: false,
|
68
|
-
limit,
|
69
|
-
nextPage: null,
|
70
|
-
page: 1,
|
71
|
-
pagingCounter: 0,
|
72
|
-
prevPage: null,
|
73
|
-
totalDocs: 0,
|
74
|
-
totalPages: 0
|
75
|
-
};
|
76
|
-
} else {
|
77
|
-
// set the id in an object for sorting later
|
78
|
-
selectDistinctResult.forEach(({ id }, i)=>{
|
79
|
-
orderedIDMap[id] = i;
|
80
|
-
});
|
81
|
-
orderedIDs = Object.keys(orderedIDMap);
|
82
|
-
findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs);
|
83
|
-
}
|
84
|
-
} else {
|
85
|
-
findManyArgs.limit = limitArg === 0 ? undefined : limitArg;
|
86
|
-
const offset = skip || (page - 1) * limitArg;
|
87
|
-
if (!Number.isNaN(offset)) findManyArgs.offset = offset;
|
88
|
-
if (where) {
|
89
|
-
findManyArgs.where = where;
|
90
|
-
}
|
91
|
-
findManyArgs.orderBy = orderBy.order(orderBy.column);
|
92
|
-
}
|
93
|
-
const findPromise = db.query[tableName].findMany(findManyArgs);
|
94
|
-
if (pagination !== false && (orderedIDs ? orderedIDs?.length <= limit : true)) {
|
95
|
-
const selectCountMethods = [];
|
96
|
-
joins.forEach(({ condition, table })=>{
|
97
|
-
selectCountMethods.push({
|
98
|
-
args: [
|
99
|
-
table,
|
100
|
-
condition
|
101
|
-
],
|
102
|
-
method: 'leftJoin'
|
103
|
-
});
|
104
|
-
});
|
105
|
-
const countResult = await chainMethods({
|
106
|
-
methods: selectCountMethods,
|
107
|
-
query: db.select({
|
108
|
-
count: sql`count
|
109
|
-
(DISTINCT ${adapter.tables[tableName].id})`
|
110
|
-
}).from(table).where(where)
|
111
|
-
});
|
112
|
-
totalDocs = Number(countResult[0].count);
|
113
|
-
totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1;
|
114
|
-
hasPrevPage = page > 1;
|
115
|
-
hasNextPage = totalPages > page;
|
116
|
-
pagingCounter = (page - 1) * limit + 1;
|
117
|
-
}
|
118
|
-
const rawDocs = await findPromise;
|
119
|
-
// sort rawDocs from selectQuery
|
120
|
-
if (Object.keys(orderedIDMap).length > 0) {
|
121
|
-
rawDocs.sort((a, b)=>orderedIDMap[a.id] - orderedIDMap[b.id]);
|
122
|
-
}
|
123
|
-
if (pagination === false || !totalDocs) {
|
124
|
-
totalDocs = rawDocs.length;
|
125
|
-
totalPages = 1;
|
126
|
-
pagingCounter = 1;
|
127
|
-
hasPrevPage = false;
|
128
|
-
hasNextPage = false;
|
129
|
-
}
|
130
|
-
const docs = rawDocs.map((data)=>{
|
131
|
-
return transform({
|
132
|
-
adapter,
|
133
|
-
config: adapter.payload.config,
|
134
|
-
data,
|
135
|
-
fields
|
136
|
-
});
|
137
|
-
});
|
138
|
-
return {
|
139
|
-
docs,
|
140
|
-
hasNextPage,
|
141
|
-
hasPrevPage,
|
142
|
-
limit,
|
143
|
-
nextPage: hasNextPage ? page + 1 : null,
|
144
|
-
page,
|
145
|
-
pagingCounter,
|
146
|
-
prevPage: hasPrevPage ? page - 1 : null,
|
147
|
-
totalDocs,
|
148
|
-
totalPages
|
149
|
-
};
|
150
|
-
};
|
151
|
-
|
152
|
-
//# 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 { 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 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 joins.forEach(({ condition, table }) => {\n selectCountMethods.push({\n args: [table, condition],\n method: 'leftJoin',\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 adapter,\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","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","countResult","methods","select","count","from","Math","ceil","rawDocs","a","b","map","data","config","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,OAAO,EAAEC,GAAG,QAAQ,cAAa;AAK1C,OAAOC,gBAAgB,2BAA0B;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dapter } from '../types.js';
|
3
|
-
import type { Result } from './buildFindManyArgs.js';
|
4
|
-
type TraverseFieldArgs = {
|
5
|
-
_locales: Result;
|
6
|
-
adapter: PostgresAdapter;
|
7
|
-
currentArgs: Result;
|
8
|
-
currentTableName: string;
|
9
|
-
depth?: number;
|
10
|
-
fields: Field[];
|
11
|
-
path: string;
|
12
|
-
topLevelArgs: Record<string, unknown>;
|
13
|
-
topLevelTableName: string;
|
14
|
-
};
|
15
|
-
export declare const traverseFields: ({ _locales, adapter, currentArgs, currentTableName, depth, fields, path, topLevelArgs, topLevelTableName, }: TraverseFieldArgs) => Record<string, unknown>;
|
16
|
-
export {};
|
17
|
-
//# sourceMappingURL=traverseFields.d.ts.map
|
@@ -1 +0,0 @@
|
|
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;AAClD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,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,4BA8KnB,CAAA"}
|
@@ -1,156 +0,0 @@
|
|
1
|
-
/* eslint-disable no-param-reassign */ import { fieldAffectsData, tabHasName } from 'payload/types';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
export const traverseFields = ({ _locales, adapter, currentArgs, currentTableName, depth, fields, path, topLevelArgs, topLevelTableName })=>{
|
4
|
-
fields.forEach((field)=>{
|
5
|
-
// handle simple relationship
|
6
|
-
if (depth > 0 && (field.type === 'upload' || field.type === 'relationship' && !field.hasMany && typeof field.relationTo === 'string')) {
|
7
|
-
if (field.localized) {
|
8
|
-
_locales.with[`${path}${field.name}`] = true;
|
9
|
-
} else {
|
10
|
-
currentArgs.with[`${path}${field.name}`] = true;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
if (field.type === 'collapsible' || field.type === 'row') {
|
14
|
-
traverseFields({
|
15
|
-
_locales,
|
16
|
-
adapter,
|
17
|
-
currentArgs,
|
18
|
-
currentTableName,
|
19
|
-
depth,
|
20
|
-
fields: field.fields,
|
21
|
-
path,
|
22
|
-
topLevelArgs,
|
23
|
-
topLevelTableName
|
24
|
-
});
|
25
|
-
return;
|
26
|
-
}
|
27
|
-
if (field.type === 'tabs') {
|
28
|
-
field.tabs.forEach((tab)=>{
|
29
|
-
const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path;
|
30
|
-
traverseFields({
|
31
|
-
_locales,
|
32
|
-
adapter,
|
33
|
-
currentArgs,
|
34
|
-
currentTableName,
|
35
|
-
depth,
|
36
|
-
fields: tab.fields,
|
37
|
-
path: tabPath,
|
38
|
-
topLevelArgs,
|
39
|
-
topLevelTableName
|
40
|
-
});
|
41
|
-
});
|
42
|
-
return;
|
43
|
-
}
|
44
|
-
if (fieldAffectsData(field)) {
|
45
|
-
switch(field.type){
|
46
|
-
case 'array':
|
47
|
-
{
|
48
|
-
const withArray = {
|
49
|
-
columns: {
|
50
|
-
_parentID: false
|
51
|
-
},
|
52
|
-
orderBy: ({ _order }, { asc })=>[
|
53
|
-
asc(_order)
|
54
|
-
],
|
55
|
-
with: {}
|
56
|
-
};
|
57
|
-
const arrayTableName = adapter.tableNameMap.get(`${currentTableName}_${path}${toSnakeCase(field.name)}`);
|
58
|
-
const arrayTableNameWithLocales = `${arrayTableName}${adapter.localesSuffix}`;
|
59
|
-
if (adapter.tables[arrayTableNameWithLocales]) {
|
60
|
-
withArray.with._locales = {
|
61
|
-
columns: {
|
62
|
-
id: false,
|
63
|
-
_parentID: false
|
64
|
-
},
|
65
|
-
with: {}
|
66
|
-
};
|
67
|
-
}
|
68
|
-
currentArgs.with[`${path}${field.name}`] = withArray;
|
69
|
-
traverseFields({
|
70
|
-
_locales: withArray.with._locales,
|
71
|
-
adapter,
|
72
|
-
currentArgs: withArray,
|
73
|
-
currentTableName: arrayTableName,
|
74
|
-
depth,
|
75
|
-
fields: field.fields,
|
76
|
-
path: '',
|
77
|
-
topLevelArgs,
|
78
|
-
topLevelTableName
|
79
|
-
});
|
80
|
-
break;
|
81
|
-
}
|
82
|
-
case 'select':
|
83
|
-
{
|
84
|
-
if (field.hasMany) {
|
85
|
-
const withSelect = {
|
86
|
-
columns: {
|
87
|
-
id: false,
|
88
|
-
order: false,
|
89
|
-
parent: false
|
90
|
-
},
|
91
|
-
orderBy: ({ order }, { asc })=>[
|
92
|
-
asc(order)
|
93
|
-
]
|
94
|
-
};
|
95
|
-
currentArgs.with[`${path}${field.name}`] = withSelect;
|
96
|
-
}
|
97
|
-
break;
|
98
|
-
}
|
99
|
-
case 'blocks':
|
100
|
-
field.blocks.forEach((block)=>{
|
101
|
-
const blockKey = `_blocks_${block.slug}`;
|
102
|
-
if (!topLevelArgs[blockKey]) {
|
103
|
-
const withBlock = {
|
104
|
-
columns: {
|
105
|
-
_parentID: false
|
106
|
-
},
|
107
|
-
orderBy: ({ _order }, { asc })=>[
|
108
|
-
asc(_order)
|
109
|
-
],
|
110
|
-
with: {}
|
111
|
-
};
|
112
|
-
const tableName = adapter.tableNameMap.get(`${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`);
|
113
|
-
if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {
|
114
|
-
withBlock.with._locales = {
|
115
|
-
with: {}
|
116
|
-
};
|
117
|
-
}
|
118
|
-
topLevelArgs.with[blockKey] = withBlock;
|
119
|
-
traverseFields({
|
120
|
-
_locales: withBlock.with._locales,
|
121
|
-
adapter,
|
122
|
-
currentArgs: withBlock,
|
123
|
-
currentTableName: tableName,
|
124
|
-
depth,
|
125
|
-
fields: block.fields,
|
126
|
-
path: '',
|
127
|
-
topLevelArgs,
|
128
|
-
topLevelTableName
|
129
|
-
});
|
130
|
-
}
|
131
|
-
});
|
132
|
-
break;
|
133
|
-
case 'group':
|
134
|
-
traverseFields({
|
135
|
-
_locales,
|
136
|
-
adapter,
|
137
|
-
currentArgs,
|
138
|
-
currentTableName,
|
139
|
-
depth,
|
140
|
-
fields: field.fields,
|
141
|
-
path: `${path}${field.name}_`,
|
142
|
-
topLevelArgs,
|
143
|
-
topLevelTableName
|
144
|
-
});
|
145
|
-
break;
|
146
|
-
default:
|
147
|
-
{
|
148
|
-
break;
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
});
|
153
|
-
return topLevelArgs;
|
154
|
-
};
|
155
|
-
|
156
|
-
//# sourceMappingURL=traverseFields.js.map
|
@@ -1 +0,0 @@
|
|
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: Result\n adapter: PostgresAdapter\n currentArgs: Result\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 // handle simple relationship\n if (\n depth > 0 &&\n (field.type === 'upload' ||\n (field.type === 'relationship' && !field.hasMany && typeof field.relationTo === 'string'))\n ) {\n if (field.localized) {\n _locales.with[`${path}${field.name}`] = true\n } else {\n currentArgs.with[`${path}${field.name}`] = true\n }\n }\n\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 = adapter.tableNameMap.get(\n `${currentTableName}_${path}${toSnakeCase(field.name)}`,\n )\n\n const arrayTableNameWithLocales = `${arrayTableName}${adapter.localesSuffix}`\n\n if (adapter.tables[arrayTableNameWithLocales]) {\n withArray.with._locales = {\n columns: {\n id: false,\n _parentID: false,\n },\n with: {},\n }\n }\n currentArgs.with[`${path}${field.name}`] = withArray\n\n traverseFields({\n _locales: withArray.with._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 = adapter.tableNameMap.get(\n `${topLevelTableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n withBlock.with._locales = {\n with: {},\n }\n }\n topLevelArgs.with[blockKey] = withBlock\n\n traverseFields({\n _locales: withBlock.with._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","hasMany","relationTo","localized","with","name","tabs","tab","tabPath","withArray","columns","_parentID","orderBy","_order","asc","arrayTableName","tableNameMap","get","arrayTableNameWithLocales","localesSuffix","tables","id","withSelect","order","parent","blocks","block","blockKey","slug","withBlock","tableName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","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,i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AAS,CAAC,EAAEC,MAAM,EAAE,EAAE,EAAEC,GAAG,EAAE,GAAK;wCAACA,IAAID;qCAAQ;gCAC/CT,MAAM,CAAC;4BACT;4BAEA,MAAM0B,YAAYxC,QAAQ0B,YAAY,CAACC,GAAG,CACxC,CAAC,EAAEpB,kBAAkB,QAAQ,EAAEV,YAAYuC,MAAME,IAAI,EAAE,CAAC;4BAG1D,IAAItC,QAAQ8B,MAAM,CAAC,CAAC,EAAEU,UAAU,EAAExC,QAAQ6B,aAAa,CAAC,CAAC,CAAC,EAAE;gCAC1DU,UAAUzB,IAAI,CAACf,QAAQ,GAAG;oCACxBe,MAAM,CAAC;gCACT;4BACF;4BACAR,aAAaQ,IAAI,CAACuB,SAAS,GAAGE;4BAE9BzC,eAAe;gCACbC,UAAUwC,UAAUzB,IAAI,CAACf,QAAQ;gCACjCC;gCACAC,aAAasC;gCACbrC,kBAAkBsC;gCAClBrC;gCACAC,QAAQgC,MAAMhC,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,MAAMM,IAAI,CAAC,CAAC,CAAC;wBAC7BT;wBACAC;oBACF;oBAEA;gBAEF;oBAAS;wBACP;oBACF;YACF;QACF;IACF;IAEA,OAAOD;AACT,EAAC"}
|
package/dist/find.d.ts
DELETED
package/dist/find.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
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,IA8BlB,CAAA"}
|
package/dist/find.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import { findMany } from './find/findMany.js';
|
3
|
-
export const find = async function find({ collection, limit, locale, page = 1, pagination, req = {}, sort: sortArg, where }) {
|
4
|
-
const collectionConfig = this.payload.collections[collection].config;
|
5
|
-
const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
|
6
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
|
7
|
-
return findMany({
|
8
|
-
adapter: this,
|
9
|
-
fields: collectionConfig.fields,
|
10
|
-
limit,
|
11
|
-
locale,
|
12
|
-
page,
|
13
|
-
pagination,
|
14
|
-
req,
|
15
|
-
sort,
|
16
|
-
tableName,
|
17
|
-
where
|
18
|
-
});
|
19
|
-
};
|
20
|
-
|
21
|
-
//# sourceMappingURL=find.js.map
|
package/dist/find.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find } from 'payload/database'\nimport type { PayloadRequestWithData, 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,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequestWithData,\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\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\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":["toSnakeCase","findMany","find","collection","limit","locale","page","pagination","req","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","tableNameMap","get","slug","adapter","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAA2B,EAClCC,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;IAEjF,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACnB,YAAYY,iBAAiBQ,IAAI;IAEzE,OAAOnB,SAAS;QACdoB,SAAS,IAAI;QACbC,QAAQV,iBAAiBU,MAAM;QAC/BlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
|
package/dist/findGlobal.d.ts
DELETED
package/dist/findGlobal.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
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,UA2BxB,CAAA"}
|
package/dist/findGlobal.js
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import { findMany } from './find/findMany.js';
|
3
|
-
export const findGlobal = async function findGlobal({ slug, locale, req, where }) {
|
4
|
-
const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
|
5
|
-
const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.slug));
|
6
|
-
const { docs: [doc] } = await findMany({
|
7
|
-
adapter: this,
|
8
|
-
fields: globalConfig.fields,
|
9
|
-
limit: 1,
|
10
|
-
locale,
|
11
|
-
pagination: false,
|
12
|
-
req,
|
13
|
-
tableName,
|
14
|
-
where
|
15
|
-
});
|
16
|
-
if (doc) {
|
17
|
-
doc.globalType = slug;
|
18
|
-
return doc;
|
19
|
-
}
|
20
|
-
return {};
|
21
|
-
};
|
22
|
-
|
23
|
-
//# sourceMappingURL=findGlobal.js.map
|
package/dist/findGlobal.js.map
DELETED
@@ -1 +0,0 @@
|
|
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\n const tableName = this.tableNameMap.get(toSnakeCase(globalConfig.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","tableNameMap","get","docs","doc","adapter","fields","limit","pagination","globalType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","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;IAElF,MAAMS,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACd,YAAYO,aAAaJ,IAAI;IAErE,MAAM,EACJY,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMf,SAAS;QACjBgB,SAAS,IAAI;QACbC,QAAQX,aAAaW,MAAM;QAC3BC,OAAO;QACPf;QACAgB,YAAY;QACZf;QACAO;QACAN;IACF;IAEA,IAAIU,KAAK;QACPA,IAAIK,UAAU,GAAGlB;QACjB,OAAOa;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
|
@@ -1 +0,0 @@
|
|
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,kBAsChC,CAAA"}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import { buildVersionGlobalFields } from 'payload/versions';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { findMany } from './find/findMany.js';
|
4
|
-
export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
5
|
-
const globalConfig = this.payload.globals.config.find(({ slug })=>slug === global);
|
6
|
-
const sort = typeof sortArg === 'string' ? sortArg : '-createdAt';
|
7
|
-
const tableName = this.tableNameMap.get(`_${toSnakeCase(globalConfig.slug)}${this.versionsSuffix}`);
|
8
|
-
const fields = buildVersionGlobalFields(globalConfig);
|
9
|
-
return findMany({
|
10
|
-
adapter: this,
|
11
|
-
fields,
|
12
|
-
limit,
|
13
|
-
locale,
|
14
|
-
page,
|
15
|
-
pagination,
|
16
|
-
req,
|
17
|
-
skip,
|
18
|
-
sort,
|
19
|
-
tableName,
|
20
|
-
where
|
21
|
-
});
|
22
|
-
};
|
23
|
-
|
24
|
-
//# sourceMappingURL=findGlobalVersions.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { FindGlobalVersions } from 'payload/database'\nimport type { PayloadRequestWithData, 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 PayloadRequestWithData,\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 = this.tableNameMap.get(\n `_${toSnakeCase(globalConfig.slug)}${this.versionsSuffix}`,\n )\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","toSnakeCase","findMany","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","tableName","tableNameMap","get","versionsSuffix","fields","adapter"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","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,CAA2B,EAClCC,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,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAErB,YAAYa,aAAaK,IAAI,EAAE,EAAE,IAAI,CAACI,cAAc,CAAC,CAAC;IAG5D,MAAMC,SAASxB,yBAAyBc;IAExC,OAAOZ,SAAS;QACduB,SAAS,IAAI;QACbD;QACAnB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
|
package/dist/findOne.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import type { FindOneArgs } from 'payload/database';
|
2
|
-
import type { TypeWithID } from 'payload/types';
|
3
|
-
import type { PostgresAdapter } from './types.js';
|
4
|
-
export declare function findOne<T extends TypeWithID>(this: PostgresAdapter, { collection, locale, req, where }: FindOneArgs): Promise<T>;
|
5
|
-
//# sourceMappingURL=findOne.d.ts.map
|
package/dist/findOne.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
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,EAAqD,UAAU,EAAE,MAAM,eAAe,CAAA;AAIlG,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,GAAkC,EAAE,KAAK,EAAE,EAAE,WAAW,GAC7E,OAAO,CAAC,CAAC,CAAC,CAmBZ"}
|
package/dist/findOne.js
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import toSnakeCase from 'to-snake-case';
|
2
|
-
import { findMany } from './find/findMany.js';
|
3
|
-
export async function findOne({ collection, locale, req = {}, where }) {
|
4
|
-
const collectionConfig = this.payload.collections[collection].config;
|
5
|
-
const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug));
|
6
|
-
const { docs } = await findMany({
|
7
|
-
adapter: this,
|
8
|
-
fields: collectionConfig.fields,
|
9
|
-
limit: 1,
|
10
|
-
locale,
|
11
|
-
page: 1,
|
12
|
-
pagination: false,
|
13
|
-
req,
|
14
|
-
sort: undefined,
|
15
|
-
tableName,
|
16
|
-
where
|
17
|
-
});
|
18
|
-
return docs?.[0] || null;
|
19
|
-
}
|
20
|
-
|
21
|
-
//# sourceMappingURL=findOne.js.map
|
package/dist/findOne.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOneArgs } from 'payload/database'\nimport type { PayloadRequestWithData, 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 PayloadRequestWithData, where }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n\n const tableName = this.tableNameMap.get(toSnakeCase(collectionConfig.slug))\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":["toSnakeCase","findMany","findOne","collection","locale","req","where","collectionConfig","payload","collections","config","tableName","tableNameMap","get","slug","docs","adapter","fields","limit","page","pagination","sort","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAA2B,EAAEC,KAAK,EAAe;IAE9E,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACN,WAAW,CAACO,MAAM;IAE/F,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAACb,YAAYO,iBAAiBO,IAAI;IAEzE,MAAM,EAAEC,IAAI,EAAE,GAAG,MAAMd,SAAS;QAC9Be,SAAS,IAAI;QACbC,QAAQV,iBAAiBU,MAAM;QAC/BC,OAAO;QACPd;QACAe,MAAM;QACNC,YAAY;QACZf;QACAgB,MAAMC;QACNX;QACAL;IACF;IAEA,OAAOS,MAAM,CAAC,EAAE,IAAI;AACtB"}
|
package/dist/findVersions.d.ts
DELETED
@@ -1 +0,0 @@
|
|
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,YAoC1B,CAAA"}
|
package/dist/findVersions.js
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
import { buildVersionCollectionFields } from 'payload/versions';
|
2
|
-
import toSnakeCase from 'to-snake-case';
|
3
|
-
import { findMany } from './find/findMany.js';
|
4
|
-
export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
|
5
|
-
const collectionConfig = this.payload.collections[collection].config;
|
6
|
-
const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
|
7
|
-
const tableName = this.tableNameMap.get(`_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`);
|
8
|
-
const fields = buildVersionCollectionFields(collectionConfig);
|
9
|
-
return findMany({
|
10
|
-
adapter: this,
|
11
|
-
fields,
|
12
|
-
limit,
|
13
|
-
locale,
|
14
|
-
page,
|
15
|
-
pagination,
|
16
|
-
req,
|
17
|
-
skip,
|
18
|
-
sort,
|
19
|
-
tableName,
|
20
|
-
where
|
21
|
-
});
|
22
|
-
};
|
23
|
-
|
24
|
-
//# sourceMappingURL=findVersions.js.map
|
package/dist/findVersions.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { FindVersions } from 'payload/database'\nimport type { PayloadRequestWithData, SanitizedCollectionConfig } from 'payload/types'\n\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 findVersions: FindVersions = async function findVersions(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequestWithData,\n skip,\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\n const tableName = this.tableNameMap.get(\n `_${toSnakeCase(collectionConfig.slug)}${this.versionsSuffix}`,\n )\n\n const fields = buildVersionCollectionFields(collectionConfig)\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":["buildVersionCollectionFields","toSnakeCase","findMany","findVersions","collection","limit","locale","page","pagination","req","skip","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","tableNameMap","get","slug","versionsSuffix","fields","adapter"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAC/D,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,QAAQ,QAAQ,qBAAoB;AAE7C,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAA2B,EAClCC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IAEjF,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CACrC,CAAC,CAAC,EAAEpB,YAAYa,iBAAiBQ,IAAI,EAAE,EAAE,IAAI,CAACC,cAAc,CAAC,CAAC;IAGhE,MAAMC,SAASxB,6BAA6Bc;IAE5C,OAAOZ,SAAS;QACduB,SAAS,IAAI;QACbD;QACAnB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
|
package/dist/init.d.ts
DELETED
package/dist/init.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAY5C,eAAO,MAAM,IAAI,EAAE,IA6FlB,CAAA"}
|