Using some() and every() with JayData OData provider

Author: Robert Bonay
13 December 2012

OData

Example to use some()

//categories, which have articles created in the lase 24 hours 
var lastDay = new Date(); 
lastDay.setDate(lastDay.getDate() - 1); 
var subFilter = context.Articles 
    .filter(function (articles) { return articles.CreateDate > this.from; }, { from: lastDay }); 
context.Categories 
    .filter(function (category) { return category.Articles.some(this.subFilter); }, { subFilter: subFilter }) 
    .toArray(function (categories) { 
}); 

 

Example to use every()

//Groups when all users in group are enabled 
var users = context.Users.filter(function (user) { return user.Enabled == true; });
context.Groups
    .filter(function (group) { group.Users.every(this.subFilter); }, { subFilter: users })
    .toArray(function (groups) {
});

 

Note: this feature is limited to OData provider.

Share this

categories: OData

Leave a comment

comments powered by Disqus