Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2806

Re: XSDS (XS Data Services)

$
0
0

Here's what I would do.

 


function inList(col,filtvals) {

  var cond0 = col.$eq(filtvals[0]);   filtvals.splice(0,1);   var cond = filtvals.reduce(function(prev, curr){     return prev.$or(col.$eq(curr));   },cond0);   return cond;

}



// First Filter both columns

var cond1 = inList(entity.col1,filtvals1);

var cond2 = inList(entity.col2,filtvals2);


var finalCond = cond1.$and(cond2);


var qry = entity.$query().$where(finalCond); 

qry.$execute(); 

You can repeat this any number of times for any number of fields. Call "inList" once for each field, and combine all the results of inList with a nested $and call.

 

You could make it more elegant by structuring all the fields and their corresponding filtvals as an array of JSON objects, and thereby wrap the whole thing in another reduce call. That might be an exercise for a later day, but this should serve your purpose for now.

 

Message was edited by: Suhas Karnik


Viewing all articles
Browse latest Browse all 2806

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>