VIE icon indicating copy to clipboard operation
VIE copied to clipboard

Provide filter method for entities

Open neogermi opened this issue 12 years ago • 2 comments

Though a developer could use the underscore filter method. It might be worth giving the developer some convenience methods at hand to enable him/her to filter entities

  • by Type
  • by Attribute

directly within VIE.

I'm thinking of something like:

var persons = vie.entities.filter({type: "Person"});
var entitiesWithNames = vie.entities.filter({attributes: [{"schema:name" : "*"}]});
var personsWithNameParis = vie.entities.filter({attributes: [{"type: "Person", "schema:name" : "Paris*"}]});

The idea here is to provide simple implementations of often-used functionality. Not to provide a full scope of all possible filter queries. For that, the native filter method should be used (which is still possible, given the above syntax).

neogermi avatar Jun 04 '12 07:06 neogermi

Sounds very useful. Have you seen the new Collection where method in Backbone? That would probably be the right place instead of filter

bergie avatar Jun 04 '12 08:06 bergie

No, haven't seen that before but I just gave it a try. My only issue with this is that it is actually a bit too simple. No regular expressions seem to work here. And filtering for types including their hierarchy would not be possible with that.

I will work on the above API during this week's hackathon in Copenhagen and we can discuss on this in Salzburg the week after.

neogermi avatar Jun 04 '12 09:06 neogermi