build/Query/EagerUtils.js
function eagerPattern(neode, depth, alias, rel) {
    var builder = new _Builder2.default();

    var name = rel.name();
    var type = rel.type();
    var relationship = rel.relationship();
    var direction = rel.direction();
    var target = rel.target();
    var relationship_variable = alias + '_' + name + '_rel';
    var node_variable = alias + '_' + name + '_node';
    var target_model = neode.model(target);

    // Build Pattern
    builder.match(alias).relationship(relationship, direction, relationship_variable).to(node_variable, target_model);

    var fields = node_variable;

    switch (type) {
        case 'node':
        case 'nodes':
            fields = eagerNode(neode, depth + 1, node_variable, target_model);
            break;

        case 'relationship':
        case 'relationships':
            fields = eagerRelationship(neode, depth + 1, relationship_variable, rel.nodeAlias(), node_variable, target_model);

    }

    var pattern = name + ': [ ' + builder.pattern().trim() + ' | ' + fields + ' ]';

    // Get the first?
    if (type === 'node' || type === 'relationship') {
        return pattern + '[0]';
    }

    return pattern;
}
function eagerPattern(neode, depth, alias, rel) {
    var builder = new _Builder2.default();

    var name = rel.name();
    var type = rel.type();
    var relationship = rel.relationship();
    var direction = rel.direction();
    var target = rel.target();
    var relationship_variable = alias + '_' + name + '_rel';
    var node_variable = alias + '_' + name + '_node';
    var target_model = neode.model(target);

    // Build Pattern
    builder.match(alias).relationship(relationship, direction, relationship_variable).to(node_variable, target_model);

    var fields = node_variable;

    switch (type) {
        case 'node':
        case 'nodes':
            fields = eagerNode(neode, depth + 1, node_variable, target_model);
            break;

        case 'relationship':
        case 'relationships':
            fields = eagerRelationship(neode, depth + 1, relationship_variable, rel.nodeAlias(), node_variable, target_model);

    }

    var pattern = name + ': [ ' + builder.pattern().trim() + ' | ' + fields + ' ]';

    // Get the first?
    if (type === 'node' || type === 'relationship') {
        return pattern + '[0]';
    }

    return pattern;
}
function eagerPattern ( neode , depth , alias , rel ) { var builder = new _Builder2 . default ( ) ; var name = rel . name ( ) ; var type = rel . type ( ) ; var relationship = rel . relationship ( ) ; var direction = rel . direction ( ) ; var target = rel . target ( ) ; var relationship_variable = alias + '_' + name + '_rel' ; var node_variable = alias + '_' + name + '_node' ; var target_model = neode . model ( target ) ; // Build Pattern builder . match ( alias ) . relationship ( relationship , direction , relationship_variable ) . to ( node_variable , target_model ) ; var fields = node_variable ; switch ( type ) { case 'node' : case 'nodes' : fields = eagerNode ( neode , depth + 1 , node_variable , target_model ) ; break ; case 'relationship' : case 'relationships' : fields = eagerRelationship ( neode , depth + 1 , relationship_variable , rel . nodeAlias ( ) , node_variable , target_model ) ; } var pattern = name + ': [ ' + builder . pattern ( ) . trim ( ) + ' | ' + fields + ' ]' ; // Get the first? if ( type === 'node' || type === 'relationship' ) { return pattern + '[0]' ; } return pattern ; }
Build a pattern to use in an eager load statement

@param {Neode} neode                 Neode instance
@param {Integer} depth               Maximum depth to stop at
@param {String} alias                Alias for the starting node
@param {RelationshipType} rel        Type of relationship
Build a pattern to use in an eager load statement