Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Handle Mongoose model intitialization errors (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Jul 20, 2019
1 parent cf136b0 commit 3e1220c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion generators/service/templates/js/model/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ module.exports = function (app) {
timestamps: true
});

return mongooseClient.model('<%= camelName %>', <%= camelName %>);
// This is necessary to avoid model compilation errors in watch mode
// see https://github.com/Automattic/mongoose/issues/1251
try {
return mongooseClient.model('<%= camelName %>');
} catch (e) {
return mongooseClient.model('<%= camelName %>', <%= camelName %>);
}
};

0 comments on commit 3e1220c

Please sign in to comment.