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

Flexible queries

Expand Messages
  • anodari
    Hi! Taffy DB is a great piece of software! I m testing to use it in a CDRom project against a database with about 15k records. There are some simple method I
    Message 1 of 2 , Apr 27, 2008
    • 0 Attachment
      Hi!

      Taffy DB is a great piece of software!

      I'm testing to use it in a CDRom project against a database with about
      15k records.

      There are some simple method I could use optional parameters in a query?

      Explaining:
      Suppose I have 2 independent optional parameters to filter: Year and
      City. I want to filter only those the user has filled.

      It worked using eval:
      qry = "rsltSet = data.get({year:'" + year + "', city:'" + city + "'})";
      eval(qry);

      But that looks ugly.

      Some suggestions?

      thank you.

      Antonio
    • tacoman_cool
      I think I understand what you are trying to do and you don t need to use Eval for it. This should work: var year = 2006; var city = New York ; var rsltSet =
      Message 2 of 2 , Apr 27, 2008
      • 0 Attachment
        I think I understand what you are trying to do and you don't need to
        use Eval for it.

        This should work:

        var year = 2006;
        var city = "New York";

        var rsltSet = data.get({year:year, city:city});

        Alternatively you could also create the filter object outside of the
        get call if that makes it easier:

        var qry = {};
        if (year > 0) {
        qry["year"] = year;
        }
        if (city.length > 0)
        {
        qry["city"] = city;
        }

        var rsltSet = data.get(qry);

        Hope that helps.

        Ian


        --- In taffydb@yahoogroups.com, "anodari" <anodari@...> wrote:
        >
        > Hi!
        >
        > Taffy DB is a great piece of software!
        >
        > I'm testing to use it in a CDRom project against a database with about
        > 15k records.
        >
        > There are some simple method I could use optional parameters in a query?
        >
        > Explaining:
        > Suppose I have 2 independent optional parameters to filter: Year and
        > City. I want to filter only those the user has filled.
        >
        > It worked using eval:
        > qry = "rsltSet = data.get({year:'" + year + "', city:'" + city +
        "'})";
        > eval(qry);
        >
        > But that looks ugly.
        >
        > Some suggestions?
        >
        > thank you.
        >
        > Antonio
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.