@payloadcms/db-mongodb 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ import { buildConfig } from 'payload/config'
|
|
|
18
18
|
import { mongooseAdapter } from '@payloadcms/db-mongodb'
|
|
19
19
|
|
|
20
20
|
export default buildConfig({
|
|
21
|
-
db: mongooseAdapter({
|
|
21
|
+
db: mongooseAdapter({
|
|
22
|
+
url: process.env.DATABASE_URI,
|
|
23
|
+
}),
|
|
22
24
|
// ...rest of config
|
|
23
25
|
})
|
|
24
26
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAAE,iBAO/B,CAAA"}
|
|
@@ -10,7 +10,6 @@ Object.defineProperty(exports, "commitTransaction", {
|
|
|
10
10
|
});
|
|
11
11
|
const commitTransaction = async function commitTransaction(id) {
|
|
12
12
|
if (!this.sessions[id]?.inTransaction()) {
|
|
13
|
-
this.payload.logger.warn('commitTransaction called when no transaction exists');
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
await this.sessions[id].commitTransaction();
|
|
@@ -18,4 +17,4 @@ const commitTransaction = async function commitTransaction(id) {
|
|
|
18
17
|
delete this.sessions[id];
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
20
|
+
//# sourceMappingURL=data:application/json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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
|
5
5
|
"repository": "https://github.com/payloadcms/payload",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/mongoose-aggregate-paginate-v2": "1.0.9",
|
|
27
27
|
"mongodb-memory-server": "8.13.0",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"@payloadcms/eslint-config": "0.0.1",
|
|
29
|
+
"payload": "2.0.2"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"registry": "https://registry.npmjs.org/"
|
package/src/index.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { ClientSession, ConnectOptions, Connection } from 'mongoose'
|
|
2
|
-
import type { Payload } from 'payload'
|
|
3
|
-
import type { BaseDatabaseAdapter } from 'payload/database'
|
|
4
|
-
|
|
5
|
-
import mongoose from 'mongoose'
|
|
6
|
-
import path from 'path'
|
|
7
|
-
import { createDatabaseAdapter } from 'payload/database'
|
|
8
|
-
|
|
9
|
-
export type { MigrateDownArgs, MigrateUpArgs } from './types'
|
|
10
|
-
|
|
11
|
-
import type { CollectionModel, GlobalModel } from './types'
|
|
12
|
-
|
|
13
|
-
import { connect } from './connect'
|
|
14
|
-
import { create } from './create'
|
|
15
|
-
import { createGlobal } from './createGlobal'
|
|
16
|
-
import { createGlobalVersion } from './createGlobalVersion'
|
|
17
|
-
import { createMigration } from './createMigration'
|
|
18
|
-
import { createVersion } from './createVersion'
|
|
19
|
-
import { deleteMany } from './deleteMany'
|
|
20
|
-
import { deleteOne } from './deleteOne'
|
|
21
|
-
import { deleteVersions } from './deleteVersions'
|
|
22
|
-
import { destroy } from './destroy'
|
|
23
|
-
import { extendViteConfig } from './extendViteConfig'
|
|
24
|
-
import { extendWebpackConfig } from './extendWebpackConfig'
|
|
25
|
-
import { find } from './find'
|
|
26
|
-
import { findGlobal } from './findGlobal'
|
|
27
|
-
import { findGlobalVersions } from './findGlobalVersions'
|
|
28
|
-
import { findOne } from './findOne'
|
|
29
|
-
import { findVersions } from './findVersions'
|
|
30
|
-
import { init } from './init'
|
|
31
|
-
import { migrateFresh } from './migrateFresh'
|
|
32
|
-
import { queryDrafts } from './queryDrafts'
|
|
33
|
-
import { beginTransaction } from './transactions/beginTransaction'
|
|
34
|
-
import { commitTransaction } from './transactions/commitTransaction'
|
|
35
|
-
import { rollbackTransaction } from './transactions/rollbackTransaction'
|
|
36
|
-
import { updateGlobal } from './updateGlobal'
|
|
37
|
-
import { updateGlobalVersion } from './updateGlobalVersion'
|
|
38
|
-
import { updateOne } from './updateOne'
|
|
39
|
-
import { updateVersion } from './updateVersion'
|
|
40
|
-
|
|
41
|
-
export interface Args {
|
|
42
|
-
/** Set to false to disable auto-pluralization of collection names, Defaults to true */
|
|
43
|
-
autoPluralization?: boolean
|
|
44
|
-
/** Extra configuration options */
|
|
45
|
-
connectOptions?: ConnectOptions & {
|
|
46
|
-
/** Set false to disable $facet aggregation in non-supporting databases, Defaults to true */
|
|
47
|
-
useFacet?: boolean
|
|
48
|
-
}
|
|
49
|
-
migrationDir?: string
|
|
50
|
-
/** The URL to connect to MongoDB or false to start payload and prevent connecting */
|
|
51
|
-
url: false | string
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type MongooseAdapter = BaseDatabaseAdapter &
|
|
55
|
-
Args & {
|
|
56
|
-
collections: {
|
|
57
|
-
[slug: string]: CollectionModel
|
|
58
|
-
}
|
|
59
|
-
connection: Connection
|
|
60
|
-
globals: GlobalModel
|
|
61
|
-
mongoMemoryServer: any
|
|
62
|
-
sessions: Record<number | string, ClientSession>
|
|
63
|
-
versions: {
|
|
64
|
-
[slug: string]: CollectionModel
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
type MongooseAdapterResult = (args: { payload: Payload }) => MongooseAdapter
|
|
69
|
-
|
|
70
|
-
declare module 'payload' {
|
|
71
|
-
export interface DatabaseAdapter extends Args {
|
|
72
|
-
collections: {
|
|
73
|
-
[slug: string]: CollectionModel
|
|
74
|
-
}
|
|
75
|
-
connection: Connection
|
|
76
|
-
globals: GlobalModel
|
|
77
|
-
mongoMemoryServer: any
|
|
78
|
-
sessions: Record<number | string, ClientSession>
|
|
79
|
-
versions: {
|
|
80
|
-
[slug: string]: CollectionModel
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function mongooseAdapter({
|
|
86
|
-
autoPluralization = true,
|
|
87
|
-
connectOptions,
|
|
88
|
-
migrationDir: migrationDirArg,
|
|
89
|
-
url,
|
|
90
|
-
}: Args): MongooseAdapterResult {
|
|
91
|
-
function adapter({ payload }: { payload: Payload }) {
|
|
92
|
-
const migrationDir = migrationDirArg || path.resolve(process.cwd(), 'src/migrations')
|
|
93
|
-
mongoose.set('strictQuery', false)
|
|
94
|
-
|
|
95
|
-
extendWebpackConfig(payload.config)
|
|
96
|
-
extendViteConfig(payload.config)
|
|
97
|
-
|
|
98
|
-
return createDatabaseAdapter<MongooseAdapter>({
|
|
99
|
-
name: 'mongoose',
|
|
100
|
-
|
|
101
|
-
// Mongoose-specific
|
|
102
|
-
autoPluralization,
|
|
103
|
-
collections: {},
|
|
104
|
-
connectOptions: connectOptions || {},
|
|
105
|
-
connection: undefined,
|
|
106
|
-
globals: undefined,
|
|
107
|
-
mongoMemoryServer: undefined,
|
|
108
|
-
sessions: {},
|
|
109
|
-
url,
|
|
110
|
-
versions: {},
|
|
111
|
-
|
|
112
|
-
// DatabaseAdapter
|
|
113
|
-
beginTransaction,
|
|
114
|
-
commitTransaction,
|
|
115
|
-
connect,
|
|
116
|
-
create,
|
|
117
|
-
createGlobal,
|
|
118
|
-
createGlobalVersion,
|
|
119
|
-
createMigration,
|
|
120
|
-
createVersion,
|
|
121
|
-
defaultIDType: 'text',
|
|
122
|
-
deleteMany,
|
|
123
|
-
deleteOne,
|
|
124
|
-
deleteVersions,
|
|
125
|
-
destroy,
|
|
126
|
-
find,
|
|
127
|
-
findGlobal,
|
|
128
|
-
findGlobalVersions,
|
|
129
|
-
findOne,
|
|
130
|
-
findVersions,
|
|
131
|
-
init,
|
|
132
|
-
migrateFresh,
|
|
133
|
-
migrationDir,
|
|
134
|
-
payload,
|
|
135
|
-
queryDrafts,
|
|
136
|
-
rollbackTransaction,
|
|
137
|
-
updateGlobal,
|
|
138
|
-
updateGlobalVersion,
|
|
139
|
-
updateOne,
|
|
140
|
-
updateVersion,
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return adapter
|
|
145
|
-
}
|