mirror of
https://github.com/thinkjs/thinkjs.git
synced 2026-02-01 15:23:03 +00:00
commit
157d870840
@ -49,8 +49,15 @@ module.exports = Class({
|
||||
model: function(){
|
||||
var self = this;
|
||||
return this.connect().then(function(handle){
|
||||
var schema = self.linkId.mongoose.Schema(self.fields, self.schema_options);
|
||||
var model = handle.model(self.modelName, schema);
|
||||
var model;
|
||||
try {
|
||||
if (handle.model(self.modelName)) model = handle.model(self.modelName);
|
||||
} catch(e) {
|
||||
if (e.name === 'MissingSchemaError') {
|
||||
var schema = self.linkId.mongoose.Schema(self.fields, self.schema_options);
|
||||
model = handle.model(self.modelName, schema);
|
||||
}
|
||||
}
|
||||
return model;
|
||||
})
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user