build/Services/DeleteNode.js
function DeleteNode(neode, identity, model) {
    var to_depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MAX_EAGER_DEPTH;

    var alias = 'this';
    var to_delete = [];
    var aliases = [alias];
    var depth = 1;

    var builder = new _Builder2.default(neode).match(alias, model).whereId(alias, identity);

    // Cascade delete to relationships
    model.relationships().forEach(function (relationship) {
        switch (relationship.cascade()) {
            case 'delete':
                addCascadeDeleteNode(neode, builder, alias, relationship, aliases, to_depth);
                break;

            // case 'detach':
            //     addDetachNode(neode, builder, alias, relationship, aliases);
            //     break;
        }
    });

    // Detach Delete target node
    builder.detachDelete(alias);

    return builder.execute(_Builder.mode.WRITE);
}
function DeleteNode(neode, identity, model) {
    var to_depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : MAX_EAGER_DEPTH;

    var alias = 'this';
    var to_delete = [];
    var aliases = [alias];
    var depth = 1;

    var builder = new _Builder2.default(neode).match(alias, model).whereId(alias, identity);

    // Cascade delete to relationships
    model.relationships().forEach(function (relationship) {
        switch (relationship.cascade()) {
            case 'delete':
                addCascadeDeleteNode(neode, builder, alias, relationship, aliases, to_depth);
                break;

            // case 'detach':
            //     addDetachNode(neode, builder, alias, relationship, aliases);
            //     break;
        }
    });

    // Detach Delete target node
    builder.detachDelete(alias);

    return builder.execute(_Builder.mode.WRITE);
}
function DeleteNode ( neode , identity , model ) { var to_depth = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : MAX_EAGER_DEPTH ; var alias = 'this' ; var to_delete = [ ] ; var aliases = [ alias ] ; var depth = 1 ; var builder = new _Builder2 . default ( neode ) . match ( alias , model ) . whereId ( alias , identity ) ; // Cascade delete to relationships model . relationships ( ) . forEach ( function ( relationship ) { switch ( relationship . cascade ( ) ) { case 'delete' : addCascadeDeleteNode ( neode , builder , alias , relationship , aliases , to_depth ) ; break ; // case 'detach': //     addDetachNode(neode, builder, alias, relationship, aliases); //     break; } } ) ; // Detach Delete target node builder . detachDelete ( alias ) ; return builder . execute ( _Builder . mode . WRITE ) ; }
Delete the relationship to the other node

@param {Neode}            neode          Neode instance
@param {Builder}          builder        Query Builder
@param {String}           from_alias     Alias of node at start of the match
@param {RelationshipType} relationship   model definition
@param {Array}            aliases        Current aliases
/
function addDetachNode(neode, builder, from_alias, relationship, aliases) {
builder.withDistinct(aliases);

const rel_alias = from_alias + relationship.name() + '_rel';

builder.optionalMatch(from_alias)
.relationship(relationship.relationship(), relationship.direction(), rel_alias)
.toAnything()
.delete(rel_alias);

builder.withDistinct( aliases );
}
 
Cascade Delete a Node

@param {Neode}   neode       Neode instance
@param {Integer} identity    Neo4j internal ID of node to delete
@param {Model}   model       Model definition
@param {Integer} to_depth    Maximum deletion depth
Delete the relationship to the other node