cli/entitybuilder.js
/**
     * - find foreign entities to modify
     * - inject foreign keys where needed
     * - output changes to foreign entity
     */
- find foreign entities to modify
- inject foreign keys where needed
- output changes to foreign entity
- find foreign entities to modify - inject foreign keys where needed - output changes to foreign entity
function injectForeignFields(targetEntity) {
        switch (type) {
            case '1:1':
                return entityModifier.readEntityProperty(targetEntity, 'fields').then(function(fields) {
                    fields.push(entity.primary);
                    entityModifier.modifyEntityProperty(targetEntity, 'fields', JSON.stringify(fields));
                    return targetEntity;
                });
            case '1:many':
                break;
            case 'many:1':
                return entityModifier.readEntityProperty(targetEntity, 'fields').then(function(fields) {
                    fields.push(entity.primary);
                    entityModifier.modifyEntityProperty(targetEntity, 'fields', JSON.stringify(fields));
                    return targetEntity;
                });
            case 'many:many':
                break;
        }
    }
function injectForeignFields ( targetEntity ) { switch ( type ) { case '1:1' : return entityModifier . readEntityProperty ( targetEntity , 'fields' ) . then ( function ( fields ) { fields . push ( entity . primary ) ; entityModifier . modifyEntityProperty ( targetEntity , 'fields' , JSON . stringify ( fields ) ) ; return targetEntity ; } ) ; case '1:many' : break ; case 'many:1' : return entityModifier . readEntityProperty ( targetEntity , 'fields' ) . then ( function ( fields ) { fields . push ( entity . primary ) ; entityModifier . modifyEntityProperty ( targetEntity , 'fields' , JSON . stringify ( fields ) ) ; return targetEntity ; } ) ; case 'many:many' : break ; } }
- find foreign entities to modify
 - inject foreign keys where needed
 - output changes to foreign entity
- find foreign entities to modify - inject foreign keys where needed - output changes to foreign entity