bergie / VIE

Semantic Interaction Framework for JavaScript

Home Page:http://viejs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide filter method for entities

neogermi opened this issue · 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).

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

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.