-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schema._clone is not a function in connection.js in V8 #14082
Comments
Please provide a repro script or environment to demonstrate your issue. const mongoose = require('mongoose');
const errorSchema = require('../test/14082Import');
const Test = mongoose.model('Test', errorSchema);
async function run() {
await mongoose.connect('mongodb://localhost:27017');
await mongoose.connection.dropDatabase();
await Test.create({
name: 'Test Testerson'
});
console.log(await Test.findOne());
console.log('done');
}
run(); |
Please help me to check it
Please note that: I can run successfully if I don't use mongoose.createConnection by using your code But when I try to do this one |
I presume that For the shared library pattern, we recommend defining Mongoose in The other alternative is to export // Replace this:
module.exports = new Schema({
message: String
});
// With this:
module.exports = {
message: String
}; And do We should add some notes on shared library patterns in our docs. |
Prerequisites
Mongoose version
8.0.0
Node.js version
18.16.0
MongoDB server version
6.2.0
Typescript version (if applicable)
No response
Description
I have an internal project that includes schema created from Mongoose v5.11.17
In the main project, I upgraded Mongoose lib from v5.13.21 to v8.0.0
When try to run the code below, I got the error
dbConnection.model('StoredError', StoredErrorSchema);
(StoredErrorSchema is form internal project with v5.11.7)Line error: node_modules\mongoose\lib\connection.js line 1075
dbConnection.model('StoredError', StoredErrorSchema);
getSteps to Reproduce
Expected Behavior
Can work well
The text was updated successfully, but these errors were encountered: