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

Function addRelationDocument

graphdb.js:702–729  ·  view source on GitHub ↗
(self, relation, index, callback, between)

Source from the content-addressed store, hash-verified

700}
701
702function addRelationDocument(self, relation, index, callback, between) {
703
704 // meta.typeid (1 CLASS, 2 RELATION, 3 PRIVATE RELATION)
705 // meta.type (link to type class/relation)
706 // meta.state
707 // meta.parentindex
708 // meta.relationindex
709 // meta.size
710 // meta.data
711
712 var meta = {};
713 meta.typeid = between ? TYPE_RELATION_DOCUMENT : TYPE_RELATION;
714 meta.type = between ? { index: 0, pageindex: self.header.relationpageindex, documentindex: index, locked: false, private: true } : relation;
715 meta.state = 1;
716 meta.parentindex = 0;
717 meta.relationindex = 0;
718 meta.size = 0;
719
720 // Creates a new node
721 addNode(self, meta, function(err, relationindex) {
722
723 // Updates exiting document by updating relation index
724 updDocumentRelation(self, index, relationindex, function(err) {
725 // Returns a new relation index
726 callback(err, relationindex);
727 });
728 });
729}
730
731function findDocumentFree(self, pageindex, callback, ready) {
732

Callers 1

addRelationFunction · 0.85

Calls 3

addNodeFunction · 0.85
updDocumentRelationFunction · 0.85
callbackFunction · 0.85

Tested by

no test coverage detected