[aerogear-dev] AeroGear.js DataManager Filter Method

Kris Borchers kris at redhat.com
Thu Dec 13 11:22:24 EST 2012


Hey all, I am trying to enhance the filter method to be able to filter objects based on values nested inside other objects inside that main object. My first thought was just to use dot notation to specify the field we are filtering on but that runs into issues if the key actually has a "." in it like this:

var x = {
	sites: {
		"google.com": {
			type: "search engine"
		}
	}
}

Trying to traverse that object via:

// pseudocode
var filtered = filter({
	"x.sites.google.com.type": {
		data:  "search engine"
	}
});

would fail. I'm wondering if we should just define our own separator for the path through the object. We could use ".." (double-dot) which I think should work so something like:

// pseudocode
var filtered = filter({
	"x..sites..google.com..type": {
		data:  "search engine"
	}
});

Then I can separate on ".." and parse that way. Thoughts?


More information about the aerogear-dev mailing list