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

Re: [taffydb] Re: range filteration

Expand Messages
  • Pierre-Olivier Chassay
    Don t know if it s a good practice but I do like that invoiceList=invoicesSearch.stringify(); resultData = new TAFFY(invoiceList); if ($( #field1 ).val() !=
    Message 1 of 6 , Aug 4, 2009
    • 0 Attachment
      Don't know if it's a good practice but I do like that

      invoiceList=invoicesSearch.stringify();
      resultData = new TAFFY(invoiceList);

      if ($("#field1").val() != ""){

      invoiceList=resultData.stringify({invoice_type:{"is":$("#field1").val()}});
      resultData = new TAFFY(invoiceList);
      }
      if ($("#field2").val() != ""){

      invoiceList=resultData.stringify({invoice_paymentoption:{"is":$("#field2").val()}});
      resultData = new TAFFY(invoiceList);
      }
      and so on with my different filter I have

      resultData.forEach(function(data){
      output the data here...
      })


      tacoman_cool wrote:
      >
      >
      > Hi Irshad,
      >
      > Find doesn't actually support what you are trying to do there,
      > although it is hinting at syntax I'd like to support in the future.
      > What you can do is filter a pre-filtered list of indexes.
      >
      > fruits.find({water:{gt:80}},fruits.find({water:{lt:90}}));
      >
      > Ian
      >
      > --- In taffydb@yahoogroups.com <mailto:taffydb%40yahoogroups.com>,
      > "irshadansari_06" <irshadahmed.ansari@...> wrote:
      > >
      > > Hi All,
      > >
      > > I am using taffy 1.7.2 version.
      > > Can anyone let me know how to filter record between a specific range.
      > > eg: i want to filter records having price greater than 20 and less
      > than 50
      > >
      > > I am using the following code:
      > > fruits.find({water:{gt:80}},{water:{lt:90}});
      > >
      > > But it only fetches record greater than 80.
      > >
      > > can anyone help to fetch records between 80 and 90.
      > >
      > > Thanks in advance,
      > > Irshad
      > >
      >
      >
    • tacoman_cool
      That s certainly doable although stringify can be pretty expensive to use as part of your normal workflow. It seems to me you may want to use a little of
      Message 2 of 6 , Aug 4, 2009
      • 0 Attachment
        That's certainly doable although stringify can be pretty expensive to use as part of your normal workflow. It seems to me you may want to use a little of JavaScripts functional nature to get things done. I assume you have some kind of a "search" button. If so you'd need to add an onclick="dosearch()" and then write a function like this:

        var dosearch = function () {
        var searchObj = {};
        if ($("#field1").val() != "") {
        searchObj["invoice_type"] = {"is":$("#field1").val()};
        }
        if ($("#field2").val() != "") {
        searchObj["invoice_paymentoption"] = {"is":$("#field2").val()};
        }
        invoicesSearch.forEach(function (data) {
        //output data
        },searchObj)
        }

        --- In taffydb@yahoogroups.com, Pierre-Olivier Chassay <moonpo@...> wrote:
        >
        > Don't know if it's a good practice but I do like that
        >
        > invoiceList=invoicesSearch.stringify();
        > resultData = new TAFFY(invoiceList);
        >
        > if ($("#field1").val() != ""){
        >
        > invoiceList=resultData.stringify({invoice_type:{"is":$("#field1").val()}});
        > resultData = new TAFFY(invoiceList);
        > }
        > if ($("#field2").val() != ""){
        >
        > invoiceList=resultData.stringify({invoice_paymentoption:{"is":$("#field2").val()}});
        > resultData = new TAFFY(invoiceList);
        > }
        > and so on with my different filter I have
        >
        > resultData.forEach(function(data){
        > output the data here...
        > })
        >
        >
      • Pierre-Olivier Chassay
        Thanks works properly now I filter over 850 elements in my taffydb it s even faster than the jquery plugin table sorter!
        Message 3 of 6 , Aug 5, 2009
        • 0 Attachment
          Thanks works properly now I filter over 850 elements in my taffydb it's
          even faster than the jquery plugin table sorter!

          tacoman_cool wrote:
          >
          >
          > That's certainly doable although stringify can be pretty expensive to
          > use as part of your normal workflow. It seems to me you may want to
          > use a little of JavaScripts functional nature to get things done. I
          > assume you have some kind of a "search" button. If so you'd need to
          > add an onclick="dosearch()" and then write a function like this:
          >
          > var dosearch = function () {
          > var searchObj = {};
          > if ($("#field1").val() != "") {
          > searchObj["invoice_type"] = {"is":$("#field1").val()};
          > }
          > if ($("#field2").val() != "") {
          > searchObj["invoice_paymentoption"] = {"is":$("#field2").val()};
          > }
          > invoicesSearch.forEach(function (data) {
          > //output data
          > },searchObj)
          > }
          >
          > --- In taffydb@yahoogroups.com <mailto:taffydb%40yahoogroups.com>,
          > Pierre-Olivier Chassay <moonpo@...> wrote:
          > >
          > > Don't know if it's a good practice but I do like that
          > >
          > > invoiceList=invoicesSearch.stringify();
          > > resultData = new TAFFY(invoiceList);
          > >
          > > if ($("#field1").val() != ""){
          > >
          > >
          > invoiceList=resultData.stringify({invoice_type:{"is":$("#field1").val()}});
          > > resultData = new TAFFY(invoiceList);
          > > }
          > > if ($("#field2").val() != ""){
          > >
          > >
          > invoiceList=resultData.stringify({invoice_paymentoption:{"is":$("#field2").val()}});
          > > resultData = new TAFFY(invoiceList);
          > > }
          > > and so on with my different filter I have
          > >
          > > resultData.forEach(function(data){
          > > output the data here...
          > > })
          > >
          > >
          >
          >
        • Jonathan Buford
          Try: fruits.find({water:{gt:80}},{water:{lt:90}}); On Tue, Aug 4, 2009 at 6:18 PM,
          Message 4 of 6 , Aug 5, 2009
          • 0 Attachment
            Try:
            fruits.find({water:{gt:80}},{water:{lt:90}});

            On Tue, Aug 4, 2009 at 6:18 PM,
            irshadansari_06<irshadahmed.ansari@...> wrote:
            >
            >
            > Hi All,
            >
            > I am using taffy 1.7.2 version.
            > Can anyone let me know how to filter record between a specific range.
            > eg: i want to filter records having price greater than 20 and less than 50
            >
            > I am using the following code:
            > fruits.find({water:{gt:80}},{water:{lt:90}});
            >
            > But it only fetches record greater than 80.
            >
            > can anyone help to fetch records between 80 and 90.
            >
            > Thanks in advance,
            > Irshad
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.