MCPcopy Create free account
hub / github.com/totaljs/framework / remRelation

Function remRelation

graphdb.js:496–543  ·  view source on GitHub ↗
(self, relation, indexA, indexB, callback)

Source from the content-addressed store, hash-verified

494}
495
496function remRelation(self, relation, indexA, indexB, callback) {
497
498 var tasks = [];
499 var relA = null;
500 var relB = null;
501
502 tasks.push(function(next) {
503 self.read(indexA, function(err, doc, relid) {
504 if (doc) {
505 relA = relid;
506 next();
507 } else {
508 tasks = null;
509 next = null;
510 callback(new Error('GraphDB: Node (A) "{0}" not exists.'.format(indexA)));
511 }
512 });
513 });
514
515 tasks.push(function(next) {
516 self.read(indexB, function(err, doc, relid) {
517 if (doc) {
518 relB = relid;
519 next();
520 } else {
521 tasks = null;
522 next = null;
523 callback(new Error('GraphDB: Node (B) "{0}" not exists.'.format(indexB)));
524 }
525 });
526 });
527
528 tasks.async(function() {
529
530 if (F.isKilled)
531 return;
532
533 IMPORTATOPERATIONS++;
534 remRelationLink(self, relA, indexB, function(err, countA) {
535 remRelationLink(self, relB, indexA, function(err, countB) {
536 remRelationLink(self, relation.documentindex, indexA, function(err, countC) {
537 IMPORTATOPERATIONS--;
538 callback(null, (countA + countB + countC) > 1);
539 });
540 });
541 });
542 });
543}
544
545function remRelationLink(self, index, documentindex, callback, nochild, counter) {
546

Callers 1

insRelationFunction · 0.85

Calls 3

callbackFunction · 0.85
remRelationLinkFunction · 0.85
nextFunction · 0.70

Tested by

no test coverage detected