@payloadcms/db-postgres 3.0.0-beta.7 → 3.0.0-canary.03427d3
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 +12 -7
- package/dist/connect.js.map +1 -1
- package/dist/count.d.ts +3 -0
- package/dist/count.d.ts.map +1 -0
- package/dist/count.js +41 -0
- package/dist/count.js.map +1 -0
- package/dist/create.d.ts +1 -1
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +3 -5
- package/dist/create.js.map +1 -1
- package/dist/createGlobal.d.ts +1 -2
- package/dist/createGlobal.d.ts.map +1 -1
- package/dist/createGlobal.js +3 -5
- package/dist/createGlobal.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +3 -4
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +3 -7
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createMigration.d.ts +1 -1
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +56 -35
- package/dist/createMigration.js.map +1 -1
- package/dist/createVersion.d.ts +1 -2
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +11 -19
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteMany.d.ts +1 -1
- package/dist/deleteMany.d.ts.map +1 -1
- package/dist/deleteMany.js +2 -5
- package/dist/deleteMany.js.map +1 -1
- package/dist/deleteOne.d.ts +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +4 -7
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.d.ts +1 -1
- package/dist/deleteVersions.d.ts.map +1 -1
- package/dist/deleteVersions.js +3 -7
- package/dist/deleteVersions.js.map +1 -1
- package/dist/destroy.d.ts +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js +11 -7
- package/dist/destroy.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/find/buildFindManyArgs.d.ts +6 -2
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +4 -3
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/findMany.d.ts +1 -2
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js +5 -16
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +4 -3
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +27 -25
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/find.d.ts +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +2 -5
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +2 -5
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +3 -7
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findOne.d.ts +1 -2
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +2 -5
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +3 -7
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +20 -23
- package/dist/init.js.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +1 -1
- package/dist/migrate.js.map +1 -1
- package/dist/migrateDown.js +1 -1
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +1 -1
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.js +1 -1
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.js +1 -1
- package/dist/migrateReset.js.map +1 -1
- package/dist/migrateStatus.js +1 -1
- package/dist/migrateStatus.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 +19 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +170 -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 +191 -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 +19 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
- package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
- package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +22 -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/queries/buildAndOrConditions.d.ts +4 -5
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +1 -2
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -3
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +1 -5
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +4 -5
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +250 -146
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +4 -5
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +9 -8
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +2 -3
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queries/selectDistinct.d.ts +3 -4
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/selectDistinct.js +3 -14
- package/dist/queries/selectDistinct.js.map +1 -1
- package/dist/queryDrafts.d.ts +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +3 -8
- package/dist/queryDrafts.js.map +1 -1
- package/dist/schema/build.d.ts +12 -7
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +208 -124
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/{getTableName.d.ts → createTableName.d.ts} +6 -8
- package/dist/schema/createTableName.d.ts.map +1 -0
- package/dist/schema/createTableName.js +31 -0
- package/dist/schema/createTableName.js.map +1 -0
- package/dist/schema/idToUUID.d.ts +1 -1
- package/dist/schema/idToUUID.d.ts.map +1 -1
- package/dist/schema/idToUUID.js.map +1 -1
- package/dist/schema/setColumnID.d.ts +1 -1
- package/dist/schema/setColumnID.d.ts.map +1 -1
- package/dist/schema/setColumnID.js +2 -2
- package/dist/schema/setColumnID.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +5 -7
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +147 -63
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/schema/validateExistingBlockIsIdentical.d.ts +3 -2
- package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/schema/validateExistingBlockIsIdentical.js +15 -9
- package/dist/schema/validateExistingBlockIsIdentical.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +4 -0
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transactions/rollbackTransaction.d.ts +1 -1
- package/dist/transactions/rollbackTransaction.d.ts.map +1 -1
- package/dist/transactions/rollbackTransaction.js.map +1 -1
- package/dist/transform/read/hasManyNumber.d.ts +1 -1
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyNumber.js.map +1 -1
- package/dist/transform/read/hasManyText.d.ts +1 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.js.map +1 -1
- package/dist/transform/read/index.d.ts +5 -3
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +2 -1
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/relationship.d.ts +1 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/relationship.js +0 -4
- package/dist/transform/read/relationship.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +8 -3
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +70 -56
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +1 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +1 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +1 -1
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/relationships.d.ts +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/relationships.js +1 -1
- package/dist/transform/write/relationships.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +1 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +23 -6
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +7 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update.d.ts +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +3 -7
- package/dist/update.js.map +1 -1
- package/dist/updateGlobal.d.ts +1 -2
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +2 -5
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +1 -2
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +3 -7
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateVersion.d.ts +1 -2
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +3 -7
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsertRow/index.d.ts +2 -2
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +10 -7
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js +3 -3
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/types.d.ts +7 -2
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts +1 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.js +1 -1
- package/dist/utilities/hasLocalesTable.js.map +1 -1
- package/dist/utilities/pushDevSchema.d.ts.map +1 -1
- package/dist/utilities/pushDevSchema.js +1 -1
- package/dist/utilities/pushDevSchema.js.map +1 -1
- package/package.json +34 -29
- package/dist/schema/getTableName.d.ts.map +0 -1
- package/dist/schema/getTableName.js +0 -31
- package/dist/schema/getTableName.js.map +0 -1
- package/src/index.ts +0 -156
package/src/index.ts
DELETED
@@ -1,156 +0,0 @@
|
|
1
|
-
import type { Payload } from 'payload'
|
2
|
-
import type { DatabaseAdapterObj } from 'payload/database'
|
3
|
-
|
4
|
-
import fs from 'fs'
|
5
|
-
import path from 'path'
|
6
|
-
import { createDatabaseAdapter } from 'payload/database'
|
7
|
-
|
8
|
-
import type { Args, PostgresAdapter } from './types.js'
|
9
|
-
|
10
|
-
import { connect } from './connect.js'
|
11
|
-
import { create } from './create.js'
|
12
|
-
import { createGlobal } from './createGlobal.js'
|
13
|
-
import { createGlobalVersion } from './createGlobalVersion.js'
|
14
|
-
import { createMigration } from './createMigration.js'
|
15
|
-
import { createVersion } from './createVersion.js'
|
16
|
-
import { deleteMany } from './deleteMany.js'
|
17
|
-
import { deleteOne } from './deleteOne.js'
|
18
|
-
import { deleteVersions } from './deleteVersions.js'
|
19
|
-
import { destroy } from './destroy.js'
|
20
|
-
import { find } from './find.js'
|
21
|
-
import { findGlobal } from './findGlobal.js'
|
22
|
-
import { findGlobalVersions } from './findGlobalVersions.js'
|
23
|
-
import { findOne } from './findOne.js'
|
24
|
-
import { findVersions } from './findVersions.js'
|
25
|
-
import { init } from './init.js'
|
26
|
-
import { migrate } from './migrate.js'
|
27
|
-
import { migrateDown } from './migrateDown.js'
|
28
|
-
import { migrateFresh } from './migrateFresh.js'
|
29
|
-
import { migrateRefresh } from './migrateRefresh.js'
|
30
|
-
import { migrateReset } from './migrateReset.js'
|
31
|
-
import { migrateStatus } from './migrateStatus.js'
|
32
|
-
import { queryDrafts } from './queryDrafts.js'
|
33
|
-
import { beginTransaction } from './transactions/beginTransaction.js'
|
34
|
-
import { commitTransaction } from './transactions/commitTransaction.js'
|
35
|
-
import { rollbackTransaction } from './transactions/rollbackTransaction.js'
|
36
|
-
import { updateOne } from './update.js'
|
37
|
-
import { updateGlobal } from './updateGlobal.js'
|
38
|
-
import { updateGlobalVersion } from './updateGlobalVersion.js'
|
39
|
-
import { updateVersion } from './updateVersion.js'
|
40
|
-
|
41
|
-
export type { MigrateDownArgs, MigrateUpArgs } from './types.js'
|
42
|
-
|
43
|
-
export { sql } from 'drizzle-orm'
|
44
|
-
|
45
|
-
export function postgresAdapter(args: Args): DatabaseAdapterObj<PostgresAdapter> {
|
46
|
-
function adapter({ payload }: { payload: Payload }) {
|
47
|
-
const migrationDir = findMigrationDir(args.migrationDir)
|
48
|
-
const idType = args.idType || 'serial'
|
49
|
-
|
50
|
-
return createDatabaseAdapter<PostgresAdapter>({
|
51
|
-
name: 'postgres',
|
52
|
-
|
53
|
-
// Postgres-specific
|
54
|
-
blockTableNames: {},
|
55
|
-
drizzle: undefined,
|
56
|
-
enums: {},
|
57
|
-
fieldConstraints: {},
|
58
|
-
idType,
|
59
|
-
localesSuffix: args.localesSuffix || '_locales',
|
60
|
-
logger: args.logger,
|
61
|
-
pgSchema: undefined,
|
62
|
-
pool: undefined,
|
63
|
-
poolOptions: args.pool,
|
64
|
-
push: args.push,
|
65
|
-
relations: {},
|
66
|
-
relationshipsSuffix: args.relationshipsSuffix || '_rels',
|
67
|
-
schema: {},
|
68
|
-
schemaName: args.schemaName,
|
69
|
-
sessions: {},
|
70
|
-
tables: {},
|
71
|
-
versionsSuffix: args.versionsSuffix || '_v',
|
72
|
-
|
73
|
-
// DatabaseAdapter
|
74
|
-
beginTransaction,
|
75
|
-
commitTransaction,
|
76
|
-
connect,
|
77
|
-
create,
|
78
|
-
createGlobal,
|
79
|
-
createGlobalVersion,
|
80
|
-
createMigration,
|
81
|
-
createVersion,
|
82
|
-
/**
|
83
|
-
* This represents how a default ID is treated in Payload as were a field type
|
84
|
-
*/
|
85
|
-
defaultIDType: idType === 'serial' ? 'number' : 'text',
|
86
|
-
deleteMany,
|
87
|
-
deleteOne,
|
88
|
-
deleteVersions,
|
89
|
-
destroy,
|
90
|
-
find,
|
91
|
-
findGlobal,
|
92
|
-
findGlobalVersions,
|
93
|
-
findOne,
|
94
|
-
findVersions,
|
95
|
-
init,
|
96
|
-
migrate,
|
97
|
-
migrateDown,
|
98
|
-
migrateFresh,
|
99
|
-
migrateRefresh,
|
100
|
-
migrateReset,
|
101
|
-
migrateStatus,
|
102
|
-
migrationDir,
|
103
|
-
payload,
|
104
|
-
queryDrafts,
|
105
|
-
rollbackTransaction,
|
106
|
-
updateGlobal,
|
107
|
-
updateGlobalVersion,
|
108
|
-
updateOne,
|
109
|
-
updateVersion,
|
110
|
-
})
|
111
|
-
}
|
112
|
-
|
113
|
-
return {
|
114
|
-
defaultIDType: 'number',
|
115
|
-
init: adapter,
|
116
|
-
}
|
117
|
-
}
|
118
|
-
|
119
|
-
/**
|
120
|
-
* Attempt to find migrations directory.
|
121
|
-
*
|
122
|
-
* Checks for the following directories in order:
|
123
|
-
* - `migrationDir` argument from Payload config
|
124
|
-
* - `src/migrations`
|
125
|
-
* - `dist/migrations`
|
126
|
-
* - `migrations`
|
127
|
-
*
|
128
|
-
* Defaults to `src/migrations`
|
129
|
-
*
|
130
|
-
* @param migrationDir
|
131
|
-
* @returns
|
132
|
-
*/
|
133
|
-
function findMigrationDir(migrationDir?: string): string {
|
134
|
-
const cwd = process.cwd()
|
135
|
-
const srcDir = path.resolve(cwd, 'src/migrations')
|
136
|
-
const distDir = path.resolve(cwd, 'dist/migrations')
|
137
|
-
const relativeMigrations = path.resolve(cwd, 'migrations')
|
138
|
-
|
139
|
-
// Use arg if provided
|
140
|
-
if (migrationDir) return migrationDir
|
141
|
-
|
142
|
-
// Check other common locations
|
143
|
-
if (fs.existsSync(srcDir)) {
|
144
|
-
return srcDir
|
145
|
-
}
|
146
|
-
|
147
|
-
if (fs.existsSync(distDir)) {
|
148
|
-
return distDir
|
149
|
-
}
|
150
|
-
|
151
|
-
if (fs.existsSync(relativeMigrations)) {
|
152
|
-
return relativeMigrations
|
153
|
-
}
|
154
|
-
|
155
|
-
return srcDir
|
156
|
-
}
|