lib/relations.js
function(map, delimitter) {
			if (!delimitter)
				delimitter = ".";
			var self = this;
			var relations = [];
			for (var i in map)
				relations.push(i);
			//console.log("mapRelations :  relations : ", relations);
			var func = function(s, e) {
				if(!s || (!s._deep_query_node_ && !s._deep_array_))
					return s;
				var doMap = function(entry) {
					if (!entry.schema || !entry.schema.links)
						return;
					var alls = [];
					querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
						.forEach(function(relation) {
							//console.log("do map relations on : ", relation);
							var path = utils.interpret(relation.href, entry.value);
							alls.push(protoc.get(path, {
								defaultProtocole: "json",
								wrap: {
									path: map[relation.rel]
								}
							}));
						});
					var d = prom.all(alls)
						.done(function(results) {
							//console.log("mapRelations : results : ");
							//console.log(JSON.stringify(results));
							results.forEach(function(r) {
								//console.log("do : ", r, " - on : ", entry.value)
								utils.toPath(entry.value, r.path, r.result, delimitter);
							});
							return results;
						});
					promises.push(d);
				};
				var promises = [];
				if(s._deep_array_)
					s.forEach(doMap);
				else
					doMap(s);
				if (!promises.length)
					return s;
				return prom.all(promises)
					.done(function() {
						return s;
					});
			};
			func._isDone_ = true;
			return self._enqueue(func);
		}
function(map, delimitter) {
			if (!delimitter)
				delimitter = ".";
			var self = this;
			var relations = [];
			for (var i in map)
				relations.push(i);
			//console.log("mapRelations :  relations : ", relations);
			var func = function(s, e) {
				if(!s || (!s._deep_query_node_ && !s._deep_array_))
					return s;
				var doMap = function(entry) {
					if (!entry.schema || !entry.schema.links)
						return;
					var alls = [];
					querier.query(entry.schema.links, "./*?rel=in=(" + relations.join(",") + ")")
						.forEach(function(relation) {
							//console.log("do map relations on : ", relation);
							var path = utils.interpret(relation.href, entry.value);
							alls.push(protoc.get(path, {
								defaultProtocole: "json",
								wrap: {
									path: map[relation.rel]
								}
							}));
						});
					var d = prom.all(alls)
						.done(function(results) {
							//console.log("mapRelations : results : ");
							//console.log(JSON.stringify(results));
							results.forEach(function(r) {
								//console.log("do : ", r, " - on : ", entry.value)
								utils.toPath(entry.value, r.path, r.result, delimitter);
							});
							return results;
						});
					promises.push(d);
				};
				var promises = [];
				if(s._deep_array_)
					s.forEach(doMap);
				else
					doMap(s);
				if (!promises.length)
					return s;
				return prom.all(promises)
					.done(function() {
						return s;
					});
			};
			func._isDone_ = true;
			return self._enqueue(func);
		}
function ( map , delimitter ) { if ( ! delimitter ) delimitter = "." ; var self = this ; var relations = [ ] ; for ( var i in map ) relations . push ( i ) ; //console.log("mapRelations :  relations : ", relations); var func = function ( s , e ) { if ( ! s || ( ! s . _deep_query_node_ && ! s . _deep_array_ ) ) return s ; var doMap = function ( entry ) { if ( ! entry . schema || ! entry . schema . links ) return ; var alls = [ ] ; querier . query ( entry . schema . links , "./*?rel=in=(" + relations . join ( "," ) + ")" ) . forEach ( function ( relation ) { //console.log("do map relations on : ", relation); var path = utils . interpret ( relation . href , entry . value ) ; alls . push ( protoc . get ( path , { defaultProtocole : "json" , wrap : { path : map [ relation . rel ] } } ) ) ; } ) ; var d = prom . all ( alls ) . done ( function ( results ) { //console.log("mapRelations : results : "); //console.log(JSON.stringify(results)); results . forEach ( function ( r ) { //console.log("do : ", r, " - on : ", entry.value) utils . toPath ( entry . value , r . path , r . result , delimitter ) ; } ) ; return results ; } ) ; promises . push ( d ) ; } ; var promises = [ ] ; if ( s . _deep_array_ ) s . forEach ( doMap ) ; else doMap ( s ) ; if ( ! promises . length ) return s ; return prom . all ( promises ) . done ( function ( ) { return s ; } ) ; } ; func . _isDone_ = true ; return self . _enqueue ( func ) ; }
map relations in current entries values

@method mapRelations
@chainable
@param  {Object} map        the map (see examples)
@param  {String} delimitter (optional) the paths delimitter
@return {NodesChain}       this

@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)
.mapRelations({
user:"relations.user",
plant:"relations.plant"
})
.logValues();
map relations in current entries values