lib/relations.js
function() {
			var self = this;
			var relations = utils.argToArr.call(arguments);
			var func = function(s, e) {
				if(!s)
					return s;
				var alls = [];
				var doGet = function(entry) {
					if (!entry.schema || !entry.schema.links)
						return;
					var r = {
						value: entry.value,
						schema: entry.schema
					};
					querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
						.forEach(function(relation) {
							//console.log("getRelations : got : ", relation)
							var path = utils.interpret(relation.href, entry.value);
							var parsed = utils.parseRequest(path);
							var wrap = {
								rel: relation,
								href: parsed
							};
							r[relation] = wrap;
							alls.push(protoc.get(parsed, {
								wrap: wrap
							}));
						});
				}
				if(s._deep_array_)
					s.forEach(doGet);
				else if(s._deep_query_node_)
					doGet(s);
				if (alls.length)
					return prom.all(alls);
				return null;
			};
			func._isDone_ = true;
			return self._enqueue(func);
		}
function() {
			var self = this;
			var relations = utils.argToArr.call(arguments);
			var func = function(s, e) {
				if(!s)
					return s;
				var alls = [];
				var doGet = function(entry) {
					if (!entry.schema || !entry.schema.links)
						return;
					var r = {
						value: entry.value,
						schema: entry.schema
					};
					querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
						.forEach(function(relation) {
							//console.log("getRelations : got : ", relation)
							var path = utils.interpret(relation.href, entry.value);
							var parsed = utils.parseRequest(path);
							var wrap = {
								rel: relation,
								href: parsed
							};
							r[relation] = wrap;
							alls.push(protoc.get(parsed, {
								wrap: wrap
							}));
						});
				}
				if(s._deep_array_)
					s.forEach(doGet);
				else if(s._deep_query_node_)
					doGet(s);
				if (alls.length)
					return prom.all(alls);
				return null;
			};
			func._isDone_ = true;
			return self._enqueue(func);
		}
function ( ) { var self = this ; var relations = utils . argToArr . call ( arguments ) ; var func = function ( s , e ) { if ( ! s ) return s ; var alls = [ ] ; var doGet = function ( entry ) { if ( ! entry . schema || ! entry . schema . links ) return ; var r = { value : entry . value , schema : entry . schema } ; querier . query ( entry . schema . links , "./*?rel=in=(" + relations . join ( "," ) + ")" ) . forEach ( function ( relation ) { //console.log("getRelations : got : ", relation) var path = utils . interpret ( relation . href , entry . value ) ; var parsed = utils . parseRequest ( path ) ; var wrap = { rel : relation , href : parsed } ; r [ relation ] = wrap ; alls . push ( protoc . get ( parsed , { wrap : wrap } ) ) ; } ) ; } if ( s . _deep_array_ ) s . forEach ( doGet ) ; else if ( s . _deep_query_node_ ) doGet ( s ) ; if ( alls . length ) return prom . all ( alls ) ; return null ; } ; func . _isDone_ = true ; return self . _enqueue ( func ) ; }
retrieve relations described in schema links.

Inject as success in chain an object that hold each relation, their result and the associated (parsed) request object




@method getRelations
@chainable
@example
var schema3 = {
properties:{
id:{ type:"string", required:false, indexed:true },
label:{ type:"string" },
plantId:{ type:"string" },
userId:{ type:"string" }
},
links:[
{
href:"plant::{ plantId }",
rel:"plant"
},
{
href:"user::{ userId }",
rel:"user"
}
]
}
____________________________
deep.nodes({
plantId:"e1",
userId:"e1",
label:"hello"
}, schema3)
.getRelations("plant", "user")
.log();

@param a list of string arguments that gives which relation to retrieve
@return {NodesChain} this
retrieve relations described in schema links .