Answer the question
In order to leave comments, you need to log in
Checking for model existence in mongoose
Hello! I have a function
function getModel (db) {
return db.model('Test', Test, 'test');
}
Cannot overwrite `Test` model once compiled.
function getModel (db) {
var name = 'Test';
if (db.model(name)) return db.model(name);
else return db.model(name, Test, 'test');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question