Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#14679 closed enhancement (fixed)

Add the ability to use functions in queries for SimpleQueryEngine

Reported by: Tom Trenka Owned by: kriszyp
Priority: high Milestone: 1.8
Component: Data Version: 1.7.1
Keywords: SimpleQueryEngine Cc:
Blocked By: Blocking:


I recently had a need to be able to use comparison functions in a query for various (mostly Memory) do this, I made the following mod in SimpleQueryEngine?.js, starting at line 55 (of 1.7):

case "object": case "undefined":
	var queryObject = query;
	query = function(object){
		for(var key in queryObject){
			var required = queryObject[key];
			if(required && required.test){
					return false;
			} else if(typeof(required) == "function"){
				if(!required(object[key], object)){
					return false;
			} else if(required != object[key]){
				return false;
		return true;

The idea is that you can use a function of the signature (object[key], object) to return a value (probably boolean). So you could have a store with an object set that has the following signature:

{ order, name, description, foo }

...and then do a query against it like so:

query = { name: /^A*/, order: function(data, obj){ return data < } };

Change History (2)

comment:1 Changed 7 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

Fixed with [27679], not sure why it isn't showing up.

comment:2 Changed 7 years ago by bill

Component: GeneralData
Note: See TracTickets for help on using tickets.