Skip to content
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

Hot reload fails for mongoose with OverwriteModelError #309

Open
cbanbury opened this issue Feb 24, 2022 · 0 comments
Open

Hot reload fails for mongoose with OverwriteModelError #309

cbanbury opened this issue Feb 24, 2022 · 0 comments

Comments

@cbanbury
Copy link

I am trying to setup a service connected to mongodb via the mongoose adapter.

Here is a snippet of how my users.service.js looks:

const DbService	= require("moleculer-db");
const MongooseAdapter = require("moleculer-db-adapter-mongoose");
const mongoose = require("mongoose");

const schema = mongoose.Schema({
	username: String,
});

module.exports = {
	name: "users",
	mixins: [DbService],
	adapter: new MongooseAdapter(process.env.MONGO_URI),
	model: mongoose.model('users', schema),
}

Whenever I make a change to the file after running npm run dev, I get the following error on hot reload:

OverwriteModelError: Cannot overwrite `users` model once compiled.
at Mongoose.model (../mongoose/lib/index.js:549:13)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant