diff --git a/lib/datasource.js b/lib/datasource.js index a7f9005f..be663cbf 100644 --- a/lib/datasource.js +++ b/lib/datasource.js @@ -310,6 +310,8 @@ function isModelClass(cls) { return cls.prototype instanceof ModelBaseClass; } +DataSource.relationTypes = ['belongsTo', 'hasMany', 'hasAndBelongsToMany']; + /*! * Define relations for the model class from the relations object * @param modelClass @@ -357,7 +359,7 @@ DataSource.prototype.defineRelations = function(modelClass, relations) { if (relations) { for (var rn in relations) { var r = relations[rn]; - assert(['belongsTo', 'hasMany', 'hasAndBelongsToMany'].indexOf(r.type) !== -1, "Invalid relation type: " + r.type); + assert(DataSource.relationTypes.indexOf(r.type) !== -1, "Invalid relation type: " + r.type); var targetModel = isModelClass(r.model) ? r.model : this.models[r.model]; if (!targetModel) { // The target model doesn't exist, let create a place holder for it