Loading ...
Sorry, an error occurred while loading the content.

Ranges in 2.6

Expand Messages
  • Marty
    In 1.7xx I did ranges by doing two sequential query s and I could do so in 2.6 but was hoping for a more elegant solution, especially as I m building my
    Message 1 of 1 , Sep 30, 2012
    • 0 Attachment
      In 1.7xx I did ranges by doing two sequential query's and I could do so
      in 2.6 but was hoping for a more elegant solution, especially as I'm building my queries dynamically based on user input. Here's a snip of my code:

      var veh = new TAFFY([
      {
      make:"Ford",
      model:"F150",
      dealerid:30,
      certified:1},
      {
      make:"Chevrolet",
      model:"Santa Fe",
      mpgcity:23,
      dealerid:30,
      certified:0},
      {
      make:"Chevrolet",
      model:"Santa Fe",
      mpgcity:20,
      dealerid:31,
      certified:0},
      {
      make:"Ford",
      model:"escort",
      mpgcity:19,
      dealerid:31,
      certified:0},
      {
      make:"Ford",
      model:"Ranger",
      mpgcity:14,
      dealerid:31,
      certified:1}]);

      // I'm creating the query's dynamically(so they act like AND's):
      qry={};
      curmake="Ford";
      curmodel="Ranger";
      qry["make"]=curmake;
      qry["model"]=curmodel;
      vlist=TAFFY(veh(qry).get());
      // As long as each qry[] is unique, I get the "AND" result as expected.


      // The problem is with Range's
      // Example-1: this works but is only useful for small integer ranges
      var tqry=[16,17,18,19,20];
      var vlist=TAFFY(veh({mpgcity:tqry}).get());

      //Example 2: this also works
      var vlist=TAFFY(veh({mpgcity:{lt:21}},{mpgcity:{gt:15}}).get());

      // Where I need help is how to implement either a range like:
      vlist=TAFFY(veh({mpgcity:[{lt:21}&&{gt:15}]}).get()); // doesn't work
      // or to implement the 2nd example dynamically

      TIA for your help
      Marty
    Your message has been successfully submitted and would be delivered to recipients shortly.