@payloadcms/db-postgres 0.1.0-beta.9 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +32 -0
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +28 -19
- package/dist/createMigration.d.ts.map +1 -1
- package/dist/createMigration.js +29 -19
- package/dist/createVersion.js +2 -2
- package/dist/extendViteConfig.d.ts +4 -0
- package/dist/extendViteConfig.d.ts.map +1 -0
- package/dist/extendViteConfig.js +38 -0
- package/dist/extendWebpackConfig.d.ts +4 -0
- package/dist/extendWebpackConfig.d.ts.map +1 -0
- package/dist/extendWebpackConfig.js +45 -0
- package/dist/find/buildFindManyArgs.js +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -5
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +2 -4
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +63 -39
- package/dist/migrateDown.d.ts +3 -0
- package/dist/migrateDown.d.ts.map +1 -0
- package/dist/migrateDown.js +71 -0
- package/dist/migrateFresh.d.ts +6 -0
- package/dist/migrateFresh.d.ts.map +1 -0
- package/dist/migrateFresh.js +81 -0
- package/dist/migrateRefresh.d.ts +6 -0
- package/dist/migrateRefresh.d.ts.map +1 -0
- package/dist/migrateRefresh.js +109 -0
- package/dist/migrateReset.d.ts +6 -0
- package/dist/migrateReset.d.ts.map +1 -0
- package/dist/migrateReset.js +89 -0
- package/dist/queries/getTableColumnFromPath.js +2 -2
- package/dist/schema/build.d.ts +2 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +14 -11
- package/dist/schema/createIndex.d.ts +1 -1
- package/dist/schema/createIndex.d.ts.map +1 -1
- package/dist/schema/createIndex.js +12 -3
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +19 -14
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +1 -2
- package/dist/transform/read/index.js +4 -4
- package/dist/types.d.ts +7 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +51 -5
- package/dist/upsertRow/index.js +2 -2
- package/dist/utilities/createMigrationTable.d.ts.map +1 -1
- package/dist/utilities/createMigrationTable.js +1 -2
- package/dist/utilities/parseError.d.ts +5 -0
- package/dist/utilities/parseError.d.ts.map +1 -0
- package/dist/utilities/parseError.js +24 -0
- package/mock.js +1 -0
- package/package.json +5 -4
- package/dist/mock.js +0 -13
- package/dist/webpack.d.ts +0 -3
- package/dist/webpack.d.ts.map +0 -1
- package/dist/webpack.js +0 -32
- package/src/index.ts +0 -89
@@ -14,10 +14,9 @@ const createMigrationTable = async (db)=>{
|
|
14
14
|
"id" serial PRIMARY KEY NOT NULL,
|
15
15
|
"name" varchar,
|
16
16
|
"batch" numeric,
|
17
|
-
"schema" jsonb,
|
18
17
|
"updated_at" timestamp(3) with time zone DEFAULT now() NOT NULL,
|
19
18
|
"created_at" timestamp(3) with time zone DEFAULT now() NOT NULL
|
20
19
|
);`);
|
21
20
|
};
|
22
21
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvY3JlYXRlTWlncmF0aW9uVGFibGUudHMiXSwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgc3FsIH0gZnJvbSAnZHJpenpsZS1vcm0nXG5cbmltcG9ydCB0eXBlIHsgRHJpenpsZURCIH0gZnJvbSAnLi4vdHlwZXMnXG5cbmV4cG9ydCBjb25zdCBjcmVhdGVNaWdyYXRpb25UYWJsZSA9IGFzeW5jIChkYjogRHJpenpsZURCKTogUHJvbWlzZTx2b2lkPiA9PiB7XG4gIGF3YWl0IGRiLmV4ZWN1dGUoc3FsYENSRUFURSBUQUJMRSBJRiBOT1QgRVhJU1RTIFwicGF5bG9hZF9taWdyYXRpb25zXCIgKFxuICBcImlkXCIgc2VyaWFsIFBSSU1BUlkgS0VZIE5PVCBOVUxMLFxuICBcIm5hbWVcIiB2YXJjaGFyLFxuICBcImJhdGNoXCIgbnVtZXJpYyxcbiAgXCJ1cGRhdGVkX2F0XCIgdGltZXN0YW1wKDMpIHdpdGggdGltZSB6b25lIERFRkFVTFQgbm93KCkgTk9UIE5VTEwsXG4gIFwiY3JlYXRlZF9hdFwiIHRpbWVzdGFtcCgzKSB3aXRoIHRpbWUgem9uZSBERUZBVUxUIG5vdygpIE5PVCBOVUxMXG4pO2ApXG59XG4iXSwibmFtZXMiOlsiY3JlYXRlTWlncmF0aW9uVGFibGUiLCJkYiIsImV4ZWN1dGUiLCJzcWwiXSwibWFwcGluZ3MiOiI7Ozs7K0JBSWFBOzs7ZUFBQUE7Ozs0QkFKTztBQUliLE1BQU1BLHVCQUF1QixPQUFPQztJQUN6QyxNQUFNQSxHQUFHQyxPQUFPLENBQUNDLElBQUFBLGVBQUcsQ0FBQSxDQUFDOzs7Ozs7RUFNckIsQ0FBQztBQUNIIn0=
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"parseError.d.ts","sourceRoot":"","sources":["../../src/utilities/parseError.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,QAAS,OAAO,OAAO,MAAM,KAAG,MAUtD,CAAA"}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "parseError", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return parseError;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
const _pg = require("pg");
|
12
|
+
const parseError = (err, msg)=>{
|
13
|
+
let formattedMsg = `${msg}`;
|
14
|
+
if (err instanceof Error) {
|
15
|
+
formattedMsg += ` ${err.message}.`;
|
16
|
+
if (err instanceof _pg.DatabaseError) {
|
17
|
+
msg += `: ${err.message}`;
|
18
|
+
if (err.hint) msg += ` ${err.hint}.`;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return formattedMsg;
|
22
|
+
};
|
23
|
+
|
24
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsaXRpZXMvcGFyc2VFcnJvci50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBEYXRhYmFzZUVycm9yIH0gZnJvbSAncGcnXG5cbi8qKlxuICogRm9ybWF0IGVycm9yIG1lc3NhZ2Ugd2l0aCBoaW50IGlmIGF2YWlsYWJsZVxuICovXG5leHBvcnQgY29uc3QgcGFyc2VFcnJvciA9IChlcnI6IHVua25vd24sIG1zZzogc3RyaW5nKTogc3RyaW5nID0+IHtcbiAgbGV0IGZvcm1hdHRlZE1zZyA9IGAke21zZ31gXG4gIGlmIChlcnIgaW5zdGFuY2VvZiBFcnJvcikge1xuICAgIGZvcm1hdHRlZE1zZyArPSBgICR7ZXJyLm1lc3NhZ2V9LmBcbiAgICBpZiAoZXJyIGluc3RhbmNlb2YgRGF0YWJhc2VFcnJvcikge1xuICAgICAgbXNnICs9IGA6ICR7ZXJyLm1lc3NhZ2V9YFxuICAgICAgaWYgKGVyci5oaW50KSBtc2cgKz0gYCAke2Vyci5oaW50fS5gXG4gICAgfVxuICB9XG4gIHJldHVybiBmb3JtYXR0ZWRNc2dcbn1cbiJdLCJuYW1lcyI6WyJwYXJzZUVycm9yIiwiZXJyIiwibXNnIiwiZm9ybWF0dGVkTXNnIiwiRXJyb3IiLCJtZXNzYWdlIiwiRGF0YWJhc2VFcnJvciIsImhpbnQiXSwibWFwcGluZ3MiOiI7Ozs7K0JBS2FBOzs7ZUFBQUE7OztvQkFMaUI7QUFLdkIsTUFBTUEsYUFBYSxDQUFDQyxLQUFjQztJQUN2QyxJQUFJQyxlQUFlLENBQUMsRUFBRUQsSUFBSSxDQUFDO0lBQzNCLElBQUlELGVBQWVHLE9BQU87UUFDeEJELGdCQUFnQixDQUFDLENBQUMsRUFBRUYsSUFBSUksT0FBTyxDQUFDLENBQUMsQ0FBQztRQUNsQyxJQUFJSixlQUFlSyxpQkFBYSxFQUFFO1lBQ2hDSixPQUFPLENBQUMsRUFBRSxFQUFFRCxJQUFJSSxPQUFPLENBQUMsQ0FBQztZQUN6QixJQUFJSixJQUFJTSxJQUFJLEVBQUVMLE9BQU8sQ0FBQyxDQUFDLEVBQUVELElBQUlNLElBQUksQ0FBQyxDQUFDLENBQUM7UUFDdEM7SUFDRjtJQUNBLE9BQU9KO0FBQ1QifQ==
|
package/mock.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export const postgresAdapter = () => ({})
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-postgres",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.1",
|
4
4
|
"description": "The officially supported Postgres database adapter for Payload",
|
5
5
|
"repository": "https://github.com/payloadcms/payload",
|
6
6
|
"license": "MIT",
|
@@ -24,8 +24,8 @@
|
|
24
24
|
"devDependencies": {
|
25
25
|
"@types/pg": "8.10.2",
|
26
26
|
"@types/to-snake-case": "1.0.0",
|
27
|
-
"
|
28
|
-
"
|
27
|
+
"@payloadcms/eslint-config": "0.0.1",
|
28
|
+
"payload": "2.0.2"
|
29
29
|
},
|
30
30
|
"peerDependencies": {
|
31
31
|
"better-sqlite3": "^8.5.0"
|
@@ -34,7 +34,8 @@
|
|
34
34
|
"registry": "https://registry.npmjs.org/"
|
35
35
|
},
|
36
36
|
"files": [
|
37
|
-
"dist"
|
37
|
+
"dist",
|
38
|
+
"mock.js"
|
38
39
|
],
|
39
40
|
"scripts": {
|
40
41
|
"build": "pnpm build:swc && pnpm build:types",
|
package/dist/mock.js
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "postgresAdapter", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return postgresAdapter;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const postgresAdapter = ()=>({});
|
12
|
-
|
13
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9tb2NrLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBjb25zdCBwb3N0Z3Jlc0FkYXB0ZXIgPSAoKSA9PiAoe30pXG4iXSwibmFtZXMiOlsicG9zdGdyZXNBZGFwdGVyIl0sIm1hcHBpbmdzIjoiOzs7OytCQUFhQTs7O2VBQUFBOzs7QUFBTixNQUFNQSxrQkFBa0IsSUFBTyxDQUFBLENBQUMsQ0FBQSJ9
|
package/dist/webpack.d.ts
DELETED
package/dist/webpack.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI/C,eAAO,MAAM,OAAO,EAAE,OAcrB,CAAA"}
|
package/dist/webpack.js
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "webpack", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return webpack;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
12
|
-
function _interop_require_default(obj) {
|
13
|
-
return obj && obj.__esModule ? obj : {
|
14
|
-
default: obj
|
15
|
-
};
|
16
|
-
}
|
17
|
-
const webpack = (config)=>{
|
18
|
-
const aliasPath = _path.default.resolve(__dirname, 'mock.js');
|
19
|
-
return {
|
20
|
-
...config,
|
21
|
-
resolve: {
|
22
|
-
...config.resolve || {},
|
23
|
-
alias: {
|
24
|
-
...config.resolve?.alias || {},
|
25
|
-
'@payloadcms/db-postgres': aliasPath,
|
26
|
-
[_path.default.resolve(__dirname, './index')]: aliasPath
|
27
|
-
}
|
28
|
-
}
|
29
|
-
};
|
30
|
-
};
|
31
|
-
|
32
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy93ZWJwYWNrLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgV2VicGFjayB9IGZyb20gJ3BheWxvYWQvZGF0YWJhc2UnXG5cbmltcG9ydCBwYXRoIGZyb20gJ3BhdGgnXG5cbmV4cG9ydCBjb25zdCB3ZWJwYWNrOiBXZWJwYWNrID0gKGNvbmZpZykgPT4ge1xuICBjb25zdCBhbGlhc1BhdGggPSBwYXRoLnJlc29sdmUoX19kaXJuYW1lLCAnbW9jay5qcycpXG5cbiAgcmV0dXJuIHtcbiAgICAuLi5jb25maWcsXG4gICAgcmVzb2x2ZToge1xuICAgICAgLi4uKGNvbmZpZy5yZXNvbHZlIHx8IHt9KSxcbiAgICAgIGFsaWFzOiB7XG4gICAgICAgIC4uLihjb25maWcucmVzb2x2ZT8uYWxpYXMgfHwge30pLFxuICAgICAgICAnQHBheWxvYWRjbXMvZGItcG9zdGdyZXMnOiBhbGlhc1BhdGgsXG4gICAgICAgIFtwYXRoLnJlc29sdmUoX19kaXJuYW1lLCAnLi9pbmRleCcpXTogYWxpYXNQYXRoLFxuICAgICAgfSxcbiAgICB9LFxuICB9XG59XG4iXSwibmFtZXMiOlsid2VicGFjayIsImNvbmZpZyIsImFsaWFzUGF0aCIsInBhdGgiLCJyZXNvbHZlIiwiX19kaXJuYW1lIiwiYWxpYXMiXSwibWFwcGluZ3MiOiI7Ozs7K0JBSWFBOzs7ZUFBQUE7Ozs2REFGSTs7Ozs7O0FBRVYsTUFBTUEsVUFBbUIsQ0FBQ0M7SUFDL0IsTUFBTUMsWUFBWUMsYUFBSSxDQUFDQyxPQUFPLENBQUNDLFdBQVc7SUFFMUMsT0FBTztRQUNMLEdBQUdKLE1BQU07UUFDVEcsU0FBUztZQUNQLEdBQUlILE9BQU9HLE9BQU8sSUFBSSxDQUFDLENBQUM7WUFDeEJFLE9BQU87Z0JBQ0wsR0FBSUwsT0FBT0csT0FBTyxFQUFFRSxTQUFTLENBQUMsQ0FBQztnQkFDL0IsMkJBQTJCSjtnQkFDM0IsQ0FBQ0MsYUFBSSxDQUFDQyxPQUFPLENBQUNDLFdBQVcsV0FBVyxFQUFFSDtZQUN4QztRQUNGO0lBQ0Y7QUFDRiJ9
|
package/src/index.ts
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
import type { Payload } from 'payload'
|
2
|
-
|
3
|
-
import path from 'path'
|
4
|
-
import { createDatabaseAdapter } from 'payload/database'
|
5
|
-
|
6
|
-
import type { Args, PostgresAdapter, PostgresAdapterResult } from './types'
|
7
|
-
|
8
|
-
export type { MigrateDownArgs, MigrateUpArgs } from './types'
|
9
|
-
|
10
|
-
import { connect } from './connect'
|
11
|
-
import { create } from './create'
|
12
|
-
import { createGlobal } from './createGlobal'
|
13
|
-
import { createGlobalVersion } from './createGlobalVersion'
|
14
|
-
import { createMigration } from './createMigration'
|
15
|
-
import { createVersion } from './createVersion'
|
16
|
-
import { deleteMany } from './deleteMany'
|
17
|
-
import { deleteOne } from './deleteOne'
|
18
|
-
import { deleteVersions } from './deleteVersions'
|
19
|
-
import { destroy } from './destroy'
|
20
|
-
import { find } from './find'
|
21
|
-
import { findGlobal } from './findGlobal'
|
22
|
-
import { findGlobalVersions } from './findGlobalVersions'
|
23
|
-
import { findOne } from './findOne'
|
24
|
-
import { findVersions } from './findVersions'
|
25
|
-
import { init } from './init'
|
26
|
-
import { migrate } from './migrate'
|
27
|
-
import { migrateStatus } from './migrateStatus'
|
28
|
-
import { queryDrafts } from './queryDrafts'
|
29
|
-
import { beginTransaction } from './transactions/beginTransaction'
|
30
|
-
import { commitTransaction } from './transactions/commitTransaction'
|
31
|
-
import { rollbackTransaction } from './transactions/rollbackTransaction'
|
32
|
-
import { updateOne } from './update'
|
33
|
-
import { updateGlobal } from './updateGlobal'
|
34
|
-
import { updateGlobalVersion } from './updateGlobalVersion'
|
35
|
-
import { updateVersion } from './updateVersion'
|
36
|
-
import { webpack } from './webpack'
|
37
|
-
|
38
|
-
export function postgresAdapter(args: Args): PostgresAdapterResult {
|
39
|
-
function adapter({ payload }: { payload: Payload }) {
|
40
|
-
const migrationDir = args.migrationDir || path.resolve(process.cwd(), 'src/migrations')
|
41
|
-
return createDatabaseAdapter<PostgresAdapter>({
|
42
|
-
...args,
|
43
|
-
name: 'postgres',
|
44
|
-
|
45
|
-
// Postgres-specific
|
46
|
-
drizzle: undefined,
|
47
|
-
enums: {},
|
48
|
-
pool: undefined,
|
49
|
-
relations: {},
|
50
|
-
schema: {},
|
51
|
-
sessions: {},
|
52
|
-
tables: {},
|
53
|
-
|
54
|
-
// DatabaseAdapter
|
55
|
-
beginTransaction,
|
56
|
-
commitTransaction,
|
57
|
-
connect,
|
58
|
-
create,
|
59
|
-
createGlobal,
|
60
|
-
createGlobalVersion,
|
61
|
-
createMigration,
|
62
|
-
createVersion,
|
63
|
-
defaultIDType: 'number',
|
64
|
-
deleteMany,
|
65
|
-
deleteOne,
|
66
|
-
deleteVersions,
|
67
|
-
destroy,
|
68
|
-
find,
|
69
|
-
findGlobal,
|
70
|
-
findGlobalVersions,
|
71
|
-
findOne,
|
72
|
-
findVersions,
|
73
|
-
init,
|
74
|
-
migrate,
|
75
|
-
migrateStatus,
|
76
|
-
migrationDir,
|
77
|
-
payload,
|
78
|
-
queryDrafts,
|
79
|
-
rollbackTransaction,
|
80
|
-
updateGlobal,
|
81
|
-
updateGlobalVersion,
|
82
|
-
updateOne,
|
83
|
-
updateVersion,
|
84
|
-
webpack,
|
85
|
-
})
|
86
|
-
}
|
87
|
-
|
88
|
-
return adapter
|
89
|
-
}
|