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

RE: [taffydb] Finding a records

Expand Messages
  • Martin Meyers
    I did it in two steps: var qry = {}; var vlist; qry[ test_value ]={lessthan:a}; some_db.find(qry,vlist) ; qry = {}; qry[ test_value ]={gt:a}; vlist = (vlist ==
    Message 1 of 3 , Jun 26, 2008
    • 0 Attachment
      Message
      I did it in two steps:
       
      var qry = {};
      var vlist;

      qry["test_value"]={lessthan:a};
      some_db.find(qry,vlist) ;
      qry = {};
           
      qry["test_value"]={gt:a};
       vlist = (vlist == undefined) ? some_db.find(qry) : some_db.find(qry,vlist) ;
      Marty
       
       
      -----Original Message-----
      From: taffydb@yahoogroups.com [mailto:taffydb@yahoogroups.com] On Behalf Of goodi_y
      Sent: Thursday, June 26, 2008 6:34 AM
      To: taffydb@yahoogroups.com
      Subject: [taffydb] Finding a records

      I want to find all records that match "test_value > a AND test_value < b"

      some_db.find( { test_value:{ gt:a}, test_value:{ lt:b} } );

      But as result I get the rows that match "test_value > a OR test_value < b"

      Anyone got a hint?

    • tacoman_cool
      That is the way to do it. The problem is that the find function expects a JavaScript object and in JavaScript only one item can exist at a single location
      Message 2 of 3 , Jun 26, 2008
      • 0 Attachment
        That is the way to do it. The problem is that the find function
        expects a JavaScript object and in JavaScript only one item can exist
        at a single location (name) within object.

        You can get it down to one line by using the second argument of the
        find function : the filter array. What we'll do is run two finds, the
        first return an array of records for the second one to walk through.

        var records =
        some_db.find({"column":{gt:5}},some_db.find({"column":{lt:1000}}));

        Hope that helps,

        Ian

        --- In taffydb@yahoogroups.com, "Martin Meyers" <marty@...> wrote:
        >
        > I did it in two steps:
        >
        > var qry = {};
        > var vlist;
        >
        > qry["test_value"]={lessthan:a};
        > some_db.find(qry,vlist) ;
        > qry = {};
        >
        > qry["test_value"]={gt:a};
        > vlist = (vlist == undefined) ? some_db.find(qry) :
        some_db.find(qry,vlist)
        > ;
        >
        > Marty
        >
        >
        >
        > -----Original Message-----
        > From: taffydb@yahoogroups.com [mailto:taffydb@yahoogroups.com] On
        Behalf Of
        > goodi_y
        > Sent: Thursday, June 26, 2008 6:34 AM
        > To: taffydb@yahoogroups.com
        > Subject: [taffydb] Finding a records
        >
        >
        >
        > I want to find all records that match "test_value > a AND test_value
        < b"
        >
        > some_db.find( { test_value:{gt:a}, test_value:{lt:b} } );
        >
        > But as result I get the rows that match "test_value > a OR
        test_value < b"
        >
        > Anyone got a hint?
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.