lib/rhapsody/mvc/model.js
function createRelationships(rhapsodyApp) {

		var relationshipModel,
			relationshipName,
			relationship,
			relatedModel;

		this.relationships = this.relationships || {};

		for(relationshipName in this.relationships) {
			relationship = this.relationships[relationshipName];
			//If it's a valid relationship
			if(this.serverModel[relationship.type]) {
				relatedModel = rhapsodyApp.requireModel(relationship['with']);

				//If the user sets the relationship model, pass it
				//otherwise, just pass false and JugglingDB will generate it
				relationshipModel = rhapsodyApp.requireModel(relationship.through);

				//If the related model actually exists
				if(relatedModel) {
					//Creates the relationship with JugglingDB API

					if(relationship.type === 'hasAndBelongsToMany') {
						this.serverModel.hasAndBelongsToMany(relationshipName, {
							model: relatedModel,
							through: relationshipModel
						});
					}
					else {
						this.serverModel[relationship.type](relatedModel, {
							as: relationshipName,
							foreignKey: relationship.foreignKey
						});
					}

				}
				else {
					utils.Logger.error('Relationship error', '"' + relationship['with'] + '" related with "' + this.name + '" does not exist.');
				}
			}
			else {
				utils.Logger.error('Relationship error', relationship.type + ' in "' + this.name + '" is not a valid relationship');
			}
		}
	}
function createRelationships(rhapsodyApp) {

		var relationshipModel,
			relationshipName,
			relationship,
			relatedModel;

		this.relationships = this.relationships || {};

		for(relationshipName in this.relationships) {
			relationship = this.relationships[relationshipName];
			//If it's a valid relationship
			if(this.serverModel[relationship.type]) {
				relatedModel = rhapsodyApp.requireModel(relationship['with']);

				//If the user sets the relationship model, pass it
				//otherwise, just pass false and JugglingDB will generate it
				relationshipModel = rhapsodyApp.requireModel(relationship.through);

				//If the related model actually exists
				if(relatedModel) {
					//Creates the relationship with JugglingDB API

					if(relationship.type === 'hasAndBelongsToMany') {
						this.serverModel.hasAndBelongsToMany(relationshipName, {
							model: relatedModel,
							through: relationshipModel
						});
					}
					else {
						this.serverModel[relationship.type](relatedModel, {
							as: relationshipName,
							foreignKey: relationship.foreignKey
						});
					}

				}
				else {
					utils.Logger.error('Relationship error', '"' + relationship['with'] + '" related with "' + this.name + '" does not exist.');
				}
			}
			else {
				utils.Logger.error('Relationship error', relationship.type + ' in "' + this.name + '" is not a valid relationship');
			}
		}
	}
function createRelationships ( rhapsodyApp ) { var relationshipModel , relationshipName , relationship , relatedModel ; this . relationships = this . relationships || { } ; for ( relationshipName in this . relationships ) { relationship = this . relationships [ relationshipName ] ; //If it's a valid relationship if ( this . serverModel [ relationship . type ] ) { relatedModel = rhapsodyApp . requireModel ( relationship [ 'with' ] ) ; //If the user sets the relationship model, pass it //otherwise, just pass false and JugglingDB will generate it relationshipModel = rhapsodyApp . requireModel ( relationship . through ) ; //If the related model actually exists if ( relatedModel ) { //Creates the relationship with JugglingDB API if ( relationship . type === 'hasAndBelongsToMany' ) { this . serverModel . hasAndBelongsToMany ( relationshipName , { model : relatedModel , through : relationshipModel } ) ; } else { this . serverModel [ relationship . type ] ( relatedModel , { as : relationshipName , foreignKey : relationship . foreignKey } ) ; } } else { utils . Logger . error ( 'Relationship error' , '"' + relationship [ 'with' ] + '" related with "' + this . name + '" does not exist.' ) ; } } else { utils . Logger . error ( 'Relationship error' , relationship . type + ' in "' + this . name + '" is not a valid relationship' ) ; } } }
Generate all the relationships of the model
@param  {Rhapsody} rhapsodyApp
Generate all the relationships of the model