Reputation: 51
I have a taffyDB filled with productdata and want to do a query to select all products with a range between >2 and <=4
allProducts = TAFFY([
{OrderNo:'prod1',range: 3,Status:'inactive'},
{OrderNo:'prod2',range: 2,Status:'inactive'},
{OrderNo:'prod3',range: 2,Status:'inactive'},
{OrderNo:'prod4',range: 6,Status:'inactive'},
{OrderNo:'prod5',range: 5,Status:'inactive'},
I know can easily do this with this query:
allProducts({range:{gt:2}},{range:{lte:4}}).get();
but how do I dynamically construct this query with values from two dropdownboxes? I can't think of a way to achieve it because I think I can't creat an object which has 2 properties with the same name :/
Upvotes: 1
Views: 560
Reputation: 808
You shouldn't need to create an object with two properties with the same name. Just do something like this:
//assuming minValue and maxValue are defined
var lowerRange = {range: {gt: minValue}};
var upperRange = {range: {lte: maxValue}};
var results = allProducts(lowerRange, upperRange).get();
Upvotes: 1