lib/_remove.js
function getIn (client, from, nodes, callback, remove) {

    remove = remove || [];

    const outNodes = [];
    const nodeIndex = {};
    const fromIndex = {};

    if (from instanceof Array) {
        from.forEach((node) => {fromIndex[node] = true});
    } else {
        from = null;
    }

    nodes.forEach((node) => {nodeIndex[node] = true});

    client.g.V.apply(client.g, nodes).Tag('o').In(null, 'p').All((err, result) => {

        if (err = error(err, result, true)) {
            return callback(err);
        }

        if (result) {
            result.forEach((triple) => {

                // TODO collect subject (triple.id) for: subject > next > object

                // escape quotes
                let object = triple.o;
                if (triple.o.indexOf('"') > -1) {
                    triple.o = triple.o.replace(/"/g, '\\"')
                }

                // remove from > p > node triples
                if (!from || fromIndex[triple.id]) {
                    remove.push({
                        subject: triple.id,
                        predicate: triple.p,
                        object: triple.o 
                    }); 

                // don't delete nodes with more then one in connections
                } else {
                    nodeIndex[object] = false;
                }
            });

            for (let node in nodeIndex) {
                if (nodeIndex[node]) {
                    if (node.indexOf('"') > -1) {
                        node = node.replace(/"/g, '\\"');
                    }
                    outNodes.push(node);
                }
            };
        }

        callback(null, outNodes, remove);
    });
}
function getIn (client, from, nodes, callback, remove) {

    remove = remove || [];

    const outNodes = [];
    const nodeIndex = {};
    const fromIndex = {};

    if (from instanceof Array) {
        from.forEach((node) => {fromIndex[node] = true});
    } else {
        from = null;
    }

    nodes.forEach((node) => {nodeIndex[node] = true});

    client.g.V.apply(client.g, nodes).Tag('o').In(null, 'p').All((err, result) => {

        if (err = error(err, result, true)) {
            return callback(err);
        }

        if (result) {
            result.forEach((triple) => {

                // TODO collect subject (triple.id) for: subject > next > object

                // escape quotes
                let object = triple.o;
                if (triple.o.indexOf('"') > -1) {
                    triple.o = triple.o.replace(/"/g, '\\"')
                }

                // remove from > p > node triples
                if (!from || fromIndex[triple.id]) {
                    remove.push({
                        subject: triple.id,
                        predicate: triple.p,
                        object: triple.o 
                    }); 

                // don't delete nodes with more then one in connections
                } else {
                    nodeIndex[object] = false;
                }
            });

            for (let node in nodeIndex) {
                if (nodeIndex[node]) {
                    if (node.indexOf('"') > -1) {
                        node = node.replace(/"/g, '\\"');
                    }
                    outNodes.push(node);
                }
            };
        }

        callback(null, outNodes, remove);
    });
}
function getIn ( client , from , nodes , callback , remove ) { remove = remove || [ ] ; const outNodes = [ ] ; const nodeIndex = { } ; const fromIndex = { } ; if ( from instanceof Array ) { from . forEach ( ( node ) => { fromIndex [ node ] = true } ) ; } else { from = null ; } nodes . forEach ( ( node ) => { nodeIndex [ node ] = true } ) ; client . g . V . apply ( client . g , nodes ) . Tag ( 'o' ) . In ( null , 'p' ) . All ( ( err , result ) => { if ( err = error ( err , result , true ) ) { return callback ( err ) ; } if ( result ) { result . forEach ( ( triple ) => { // TODO collect subject (triple.id) for: subject > next > object // escape quotes let object = triple . o ; if ( triple . o . indexOf ( '"' ) > - 1 ) { triple . o = triple . o . replace ( / " / g , '\\"' ) } // remove from > p > node triples if ( ! from || fromIndex [ triple . id ] ) { remove . push ( { subject : triple . id , predicate : triple . p , object : triple . o } ) ; // don't delete nodes with more then one in connections } else { nodeIndex [ object ] = false ; } } ) ; for ( let node in nodeIndex ) { if ( nodeIndex [ node ] ) { if ( node . indexOf ( '"' ) > - 1 ) { node = node . replace ( / " / g , '\\"' ) ; } outNodes . push ( node ) ; } } ; } callback ( null , outNodes , remove ) ; } ) ; }
-> from network
- > from network