@payloadcms/db-mongodb 3.41.0-canary.2 → 3.41.0-canary.4
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/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +2 -1
- package/dist/connect.js.map +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js +1 -5
- package/dist/destroy.js.map +1 -1
- package/package.json +5 -5
package/dist/connect.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtC,eAAO,MAAM,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtC,eAAO,MAAM,OAAO,EAAE,OA+ErB,CAAA"}
|
package/dist/connect.js
CHANGED
@@ -24,6 +24,7 @@ export const connect = async function connect(options = {
|
|
24
24
|
// If we are running a replica set with MongoDB Memory Server,
|
25
25
|
// wait until the replica set elects a primary before proceeding
|
26
26
|
if (this.mongoMemoryServer) {
|
27
|
+
this.payload.logger.info('Waiting for MongoDB Memory Server replica set to elect a primary...');
|
27
28
|
await new Promise((resolve)=>setTimeout(resolve, 2000));
|
28
29
|
}
|
29
30
|
const client = this.connection.getClient();
|
@@ -31,7 +32,7 @@ export const connect = async function connect(options = {
|
|
31
32
|
this.transactionOptions = false;
|
32
33
|
this.beginTransaction = defaultBeginTransaction();
|
33
34
|
}
|
34
|
-
if (!
|
35
|
+
if (!hotReload) {
|
35
36
|
if (process.env.PAYLOAD_DROP_DATABASE === 'true') {
|
36
37
|
this.payload.logger.info('---- DROPPING DATABASE ----');
|
37
38
|
await mongoose.connection.dropDatabase();
|
package/dist/connect.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { ConnectOptions } from 'mongoose'\nimport type { Connect } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { defaultBeginTransaction } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const connect: Connect = async function connect(\n this: MongooseAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n if (this.url === false) {\n return\n }\n\n if (typeof this.url !== 'string') {\n throw new Error('Error: missing MongoDB connection URL.')\n }\n\n const urlToConnect = this.url\n\n const connectionOptions: { useFacet: undefined } & ConnectOptions = {\n autoIndex: true,\n ...this.connectOptions,\n useFacet: undefined,\n }\n\n if (hotReload) {\n connectionOptions.autoIndex = false\n }\n\n try {\n this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection\n\n // If we are running a replica set with MongoDB Memory Server,\n // wait until the replica set elects a primary before proceeding\n if (this.mongoMemoryServer) {\n await new Promise((resolve) => setTimeout(resolve, 2000))\n }\n\n const client = this.connection.getClient()\n\n if (!client.options.replicaSet) {\n this.transactionOptions = false\n this.beginTransaction = defaultBeginTransaction()\n }\n\n if (!
|
1
|
+
{"version":3,"sources":["../src/connect.ts"],"sourcesContent":["import type { ConnectOptions } from 'mongoose'\nimport type { Connect } from 'payload'\n\nimport mongoose from 'mongoose'\nimport { defaultBeginTransaction } from 'payload'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const connect: Connect = async function connect(\n this: MongooseAdapter,\n options = {\n hotReload: false,\n },\n) {\n const { hotReload } = options\n\n if (this.url === false) {\n return\n }\n\n if (typeof this.url !== 'string') {\n throw new Error('Error: missing MongoDB connection URL.')\n }\n\n const urlToConnect = this.url\n\n const connectionOptions: { useFacet: undefined } & ConnectOptions = {\n autoIndex: true,\n ...this.connectOptions,\n useFacet: undefined,\n }\n\n if (hotReload) {\n connectionOptions.autoIndex = false\n }\n\n try {\n this.connection = (await mongoose.connect(urlToConnect, connectionOptions)).connection\n\n // If we are running a replica set with MongoDB Memory Server,\n // wait until the replica set elects a primary before proceeding\n if (this.mongoMemoryServer) {\n this.payload.logger.info(\n 'Waiting for MongoDB Memory Server replica set to elect a primary...',\n )\n await new Promise((resolve) => setTimeout(resolve, 2000))\n }\n\n const client = this.connection.getClient()\n\n if (!client.options.replicaSet) {\n this.transactionOptions = false\n this.beginTransaction = defaultBeginTransaction()\n }\n\n if (!hotReload) {\n if (process.env.PAYLOAD_DROP_DATABASE === 'true') {\n this.payload.logger.info('---- DROPPING DATABASE ----')\n await mongoose.connection.dropDatabase()\n this.payload.logger.info('---- DROPPED DATABASE ----')\n }\n }\n\n if (this.ensureIndexes) {\n await Promise.all(\n this.payload.config.collections.map(async (coll) => {\n await this.collections[coll.slug]?.ensureIndexes()\n }),\n )\n }\n\n if (process.env.NODE_ENV === 'production' && this.prodMigrations) {\n await this.migrate({ migrations: this.prodMigrations })\n }\n } catch (err) {\n let msg = `Error: cannot connect to MongoDB.`\n\n if (typeof err === 'object' && err && 'message' in err && typeof err.message === 'string') {\n msg = `${msg} Details: ${err.message}`\n }\n\n this.payload.logger.error({\n err,\n msg,\n })\n process.exit(1)\n }\n}\n"],"names":["mongoose","defaultBeginTransaction","connect","options","hotReload","url","Error","urlToConnect","connectionOptions","autoIndex","connectOptions","useFacet","undefined","connection","mongoMemoryServer","payload","logger","info","Promise","resolve","setTimeout","client","getClient","replicaSet","transactionOptions","beginTransaction","process","env","PAYLOAD_DROP_DATABASE","dropDatabase","ensureIndexes","all","config","collections","map","coll","slug","NODE_ENV","prodMigrations","migrate","migrations","err","msg","message","error","exit"],"mappings":"AAGA,OAAOA,cAAc,WAAU;AAC/B,SAASC,uBAAuB,QAAQ,UAAS;AAIjD,OAAO,MAAMC,UAAmB,eAAeA,QAE7CC,UAAU;IACRC,WAAW;AACb,CAAC;IAED,MAAM,EAAEA,SAAS,EAAE,GAAGD;IAEtB,IAAI,IAAI,CAACE,GAAG,KAAK,OAAO;QACtB;IACF;IAEA,IA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,CAACC,cAAc,EAAE;YAChE,MAAM,IAAI,CAACC,OAAO,CAAC;gBAAEC,YAAY,IAAI,CAACF,cAAc;YAAC;QACvD;IACF,EAAE,OAAOG,KAAK;QACZ,IAAIC,MAAM,CAAC,iCAAiC,CAAC;QAE7C,IAAI,OAAOD,QAAQ,YAAYA,OAAO,aAAaA,OAAO,OAAOA,IAAIE,OAAO,KAAK,UAAU;YACzFD,MAAM,GAAGA,IAAI,UAAU,EAAED,IAAIE,OAAO,EAAE;QACxC;QAEA,IAAI,CAAC5B,OAAO,CAACC,MAAM,CAAC4B,KAAK,CAAC;YACxBH;YACAC;QACF;QACAhB,QAAQmB,IAAI,CAAC;IACf;AACF,EAAC"}
|
package/dist/destroy.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"destroy.d.ts","sourceRoot":"","sources":["../src/destroy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAMtC,eAAO,MAAM,OAAO,EAAE,OAIrB,CAAA"}
|
package/dist/destroy.js
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
import mongoose from 'mongoose';
|
2
2
|
export const destroy = async function destroy() {
|
3
|
-
|
4
|
-
await this.mongoMemoryServer.stop();
|
5
|
-
} else {
|
6
|
-
await mongoose.disconnect();
|
7
|
-
}
|
3
|
+
await mongoose.disconnect();
|
8
4
|
Object.keys(mongoose.models).map((model)=>mongoose.deleteModel(model));
|
9
5
|
};
|
10
6
|
|
package/dist/destroy.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload'\n\nimport mongoose from 'mongoose'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const destroy: Destroy = async function destroy(this: MongooseAdapter) {\n
|
1
|
+
{"version":3,"sources":["../src/destroy.ts"],"sourcesContent":["import type { Destroy } from 'payload'\n\nimport mongoose from 'mongoose'\n\nimport type { MongooseAdapter } from './index.js'\n\nexport const destroy: Destroy = async function destroy(this: MongooseAdapter) {\n await mongoose.disconnect()\n\n Object.keys(mongoose.models).map((model) => mongoose.deleteModel(model))\n}\n"],"names":["mongoose","destroy","disconnect","Object","keys","models","map","model","deleteModel"],"mappings":"AAEA,OAAOA,cAAc,WAAU;AAI/B,OAAO,MAAMC,UAAmB,eAAeA;IAC7C,MAAMD,SAASE,UAAU;IAEzBC,OAAOC,IAAI,CAACJ,SAASK,MAAM,EAAEC,GAAG,CAAC,CAACC,QAAUP,SAASQ,WAAW,CAACD;AACnE,EAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@payloadcms/db-mongodb",
|
3
|
-
"version": "3.41.0-canary.
|
3
|
+
"version": "3.41.0-canary.4",
|
4
4
|
"description": "The officially supported MongoDB database adapter for Payload",
|
5
5
|
"homepage": "https://payloadcms.com",
|
6
6
|
"repository": {
|
@@ -17,8 +17,8 @@
|
|
17
17
|
"url": "https://payloadcms.com"
|
18
18
|
}
|
19
19
|
],
|
20
|
-
"type": "module",
|
21
20
|
"sideEffects": false,
|
21
|
+
"type": "module",
|
22
22
|
"exports": {
|
23
23
|
".": {
|
24
24
|
"import": "./dist/index.js",
|
@@ -48,12 +48,12 @@
|
|
48
48
|
"@types/prompts": "^2.4.5",
|
49
49
|
"@types/uuid": "10.0.0",
|
50
50
|
"mongodb": "6.12.0",
|
51
|
-
"mongodb-memory-server": "
|
51
|
+
"mongodb-memory-server": "10.1.4",
|
52
52
|
"@payloadcms/eslint-config": "3.28.0",
|
53
|
-
"payload": "3.41.0-canary.
|
53
|
+
"payload": "3.41.0-canary.4"
|
54
54
|
},
|
55
55
|
"peerDependencies": {
|
56
|
-
"payload": "3.41.0-canary.
|
56
|
+
"payload": "3.41.0-canary.4"
|
57
57
|
},
|
58
58
|
"scripts": {
|
59
59
|
"build": "pnpm build:types && pnpm build:swc",
|