Skip to content

Commit f55d676

Browse files
committed
BREAKING CHANGE: remove browser build, move to @mongoosejs/browser instead
Fix #15296
1 parent 4748307 commit f55d676

21 files changed

+44
-595
lines changed

browser.js

-8
This file was deleted.

docs/nextjs.md

-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,4 @@ And Next.js forces ESM mode.
3434
## Next.js Edge Runtime
3535

3636
Mongoose does **not** currently support [Next.js Edge Runtime](https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes#edge-runtime).
37-
While you can import Mongoose in Edge Runtime, you'll get [Mongoose's browser library](browser.html).
3837
There is no way for Mongoose to connect to MongoDB in Edge Runtime, because [Edge Runtime currently doesn't support Node.js `net` API](https://edge-runtime.vercel.app/features/available-apis#unsupported-apis), which is what the MongoDB Node Driver uses to connect to MongoDB.

lib/browser.js

-143
This file was deleted.

lib/browserDocument.js

-117
This file was deleted.

lib/document.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,20 @@ function Document(obj, fields, skipId, options) {
9292
}
9393
options = Object.assign({}, options);
9494

95+
this.$__ = new InternalCache();
96+
9597
// Support `browserDocument.js` syntax
9698
if (this.$__schema == null) {
9799
const _schema = utils.isObject(fields) && !fields.instanceOfSchema ?
98100
new Schema(fields) :
99101
fields;
102+
100103
this.$__setSchema(_schema);
101104
fields = skipId;
102105
skipId = options;
103106
options = arguments[4] || {};
104107
}
105108

106-
this.$__ = new InternalCache();
107-
108109
// Avoid setting `isNew` to `true`, because it is `true` by default
109110
if (options.isNew != null && options.isNew !== true) {
110111
this.$isNew = options.isNew;
@@ -848,10 +849,10 @@ Document.prototype.updateOne = function updateOne(doc, options, callback) {
848849
const query = this.constructor.updateOne({ _id: this._doc._id }, doc, options);
849850
const self = this;
850851
query.pre(function queryPreUpdateOne() {
851-
return self.constructor._middleware.execPre('updateOne', self, [self]);
852+
return self._execDocumentPreHooks('updateOne', [self]);
852853
});
853854
query.post(function queryPostUpdateOne() {
854-
return self.constructor._middleware.execPost('updateOne', self, [self], {});
855+
return self._execDocumentPostHooks('updateOne');
855856
});
856857

857858
if (this.$session() != null) {
@@ -2903,15 +2904,15 @@ function _pushNestedArrayPaths(val, paths, path) {
29032904
*/
29042905

29052906
Document.prototype._execDocumentPreHooks = async function _execDocumentPreHooks(opName, ...args) {
2906-
return this.constructor._middleware.execPre(opName, this, [...args]);
2907+
return this.$__middleware.execPre(opName, this, [...args]);
29072908
};
29082909

29092910
/*!
29102911
* ignore
29112912
*/
29122913

29132914
Document.prototype._execDocumentPostHooks = async function _execDocumentPostHooks(opName, error) {
2914-
return this.constructor._middleware.execPost(opName, this, [this], { error });
2915+
return this.$__middleware.execPost(opName, this, [this], { error });
29152916
};
29162917

29172918
/*!
@@ -3653,6 +3654,7 @@ Document.prototype.$__setSchema = function(schema) {
36533654
this.schema = schema;
36543655
}
36553656
this.$__schema = schema;
3657+
this.$__middleware = schema._getDocumentMiddleware();
36563658
this[documentSchemaSymbol] = schema;
36573659
};
36583660

lib/documentProvider.js

-30
This file was deleted.

lib/drivers/browser/binary.js

-14
This file was deleted.

lib/drivers/browser/decimal128.js

-7
This file was deleted.

0 commit comments

Comments
 (0)