build/Services/WriteUtils.js
function addNodeRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) {
    if (aliases.length > MAX_CREATE_DEPTH) {
        return;
    }

    // If Node is passed, attempt to create a relationship to that specific node
    if (value instanceof _Node2.default) {
        builder.match(target_alias).whereId(target_alias, value.identity());
    }
    // If Primary key is passed then try to match on that
    else if (typeof value == 'string' || typeof value == 'number') {
            var model = neode.model(relationship.target());

            builder.merge(target_alias, model, _defineProperty({}, model.primaryKey(), value));
        }
        // If Map is passed, attempt to create that node and then relate
        // TODO: What happens when we need to validate this?
        // TODO: Is mergeFields() the right option here?
        else if (Object.keys(value).length) {
                var _model2 = neode.model(relationship.target());
                value = _GenerateDefaultValues2.default.async(neode, _model2, value);

                addNodeToStatement(neode, builder, target_alias, _model2, value, aliases, mode, _model2.mergeFields());
            }

    // Create the Relationship
    builder[mode](alias).relationship(relationship.relationship(), relationship.direction(), rel_alias).to(target_alias);
}
function addNodeRelationshipToStatement(neode, builder, alias, rel_alias, target_alias, relationship, value, aliases, mode) {
    if (aliases.length > MAX_CREATE_DEPTH) {
        return;
    }

    // If Node is passed, attempt to create a relationship to that specific node
    if (value instanceof _Node2.default) {
        builder.match(target_alias).whereId(target_alias, value.identity());
    }
    // If Primary key is passed then try to match on that
    else if (typeof value == 'string' || typeof value == 'number') {
            var model = neode.model(relationship.target());

            builder.merge(target_alias, model, _defineProperty({}, model.primaryKey(), value));
        }
        // If Map is passed, attempt to create that node and then relate
        // TODO: What happens when we need to validate this?
        // TODO: Is mergeFields() the right option here?
        else if (Object.keys(value).length) {
                var _model2 = neode.model(relationship.target());
                value = _GenerateDefaultValues2.default.async(neode, _model2, value);

                addNodeToStatement(neode, builder, target_alias, _model2, value, aliases, mode, _model2.mergeFields());
            }

    // Create the Relationship
    builder[mode](alias).relationship(relationship.relationship(), relationship.direction(), rel_alias).to(target_alias);
}
function addNodeRelationshipToStatement ( neode , builder , alias , rel_alias , target_alias , relationship , value , aliases , mode ) { if ( aliases . length > MAX_CREATE_DEPTH ) { return ; } // If Node is passed, attempt to create a relationship to that specific node if ( value instanceof _Node2 . default ) { builder . match ( target_alias ) . whereId ( target_alias , value . identity ( ) ) ; } // If Primary key is passed then try to match on that else if ( typeof value == 'string' || typeof value == 'number' ) { var model = neode . model ( relationship . target ( ) ) ; builder . merge ( target_alias , model , _defineProperty ( { } , model . primaryKey ( ) , value ) ) ; } // If Map is passed, attempt to create that node and then relate // TODO: What happens when we need to validate this? // TODO: Is mergeFields() the right option here? else if ( Object . keys ( value ) . length ) { var _model2 = neode . model ( relationship . target ( ) ) ; value = _GenerateDefaultValues2 . default . async ( neode , _model2 , value ) ; addNodeToStatement ( neode , builder , target_alias , _model2 , value , aliases , mode , _model2 . mergeFields ( ) ) ; } // Create the Relationship builder [ mode ] ( alias ) . relationship ( relationship . relationship ( ) , relationship . direction ( ) , rel_alias ) . to ( target_alias ) ; }
Add a node relationship to the current statement

@param {Neode}           neode           Neode instance
@param {Builder}         builder         Query builder
@param {String}          alias           Current node alias
@param {String}          rel_alias       Generated alias for the relationship
@param {String}          target_alias    Generated alias for the relationship
@param {Relationship}    relationship    Model
@param {Object}          value           Value map
@param {Array}           aliases         Aliases to carry through in with statement
@param {String}  mode        'create' or 'merge'
Add a node relationship to the current statement