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

Re: Retrieve unique values

Expand Messages
  • tacoman_cool
    It very much would. The reason it hasn t to date is to save space in the .js file and to focus on the API more on the things people have been asking for.
    Message 1 of 7 , Nov 21, 2008
    • 0 Attachment
      It very much would. The reason it hasn't to date is to save space in
      the .js file and to focus on the API more on the things people have
      been asking for. Personally I'd like to look at returning an special
      object from get() that would be able to do this type of thing.

      So you could do:
      collection.get({addressState:"WA"}).getUniques("somecolumn");

      or, as in our other discussion:

      collection.get({addressState:"WA"}).subSelect(["col1","col2");

      Any thoughts?

      --- In taffydb@yahoogroups.com, "focus2friends" <focus2friends@...> wrote:
      >
      > Wouldn't it be easier if you could select a specified field (column)
      values from the
      > collection and do a gatherUnique on that resultset?
      >
      > --- In taffydb@yahoogroups.com, "tacoman_cool" <ian@> wrote:
      > >
      > > The way to do that is using the Taffy Utility function
      > > TAFFY.gatherUniques.
      > >
      > > You'll need to build a bit of a wrapper though. Something like:
      > >
      > > optionsDB.getOptGroups = function () {
      > > var x = [];
      > > optionsDB.forEach(function (r) {x[x.length] = r.optgroup});
      > > return TAFFY.gatherUniques(x);
      > > }
      > >
      > > That should return an array of unique values.
      > >
      > > --- In taffydb@yahoogroups.com, "focus2friends" <focus2friends@>
      wrote:
      > > >
      > > > I've a Taffy collection where each row contains 2 fields (see
      > > snippet below). Now I want to
      > > > retrieve the unique values of the "optgroup" field, so the resultset
      > > should contain "Tires",
      > > > "Color" and "Interior".
      > > >
      > > > What's the easiest way to do this with Taffy?
      > > >
      > > >
      > > >
      > > >
      > > > var options = [
      > > > {"optname":"195SR14", "optgroup":"Tires"},
      > > > {"optname":"185SR13", "optgroup":"Tires"},
      > > > {"optname":"180SR14", "optgroup":"Tires"},
      > > > {"optname":"Blue", "optgroup":"Color"},
      > > > {"optname":"Red", "optgroup":"Color"},
      > > > {"optname":"Black", "optgroup":"Color"},
      > > > {"optname":"Silver", "optgroup":"Color"},
      > > > {"optname":"Green", "optgroup":"Color"},
      > > > {"optname":"Leather", "optgroup":"Interior"},
      > > > {"optname":"Vinyl", "optgroup":"Interior"}
      > > > ];
      > > >
      > > > var optionsDB = new TAFFY(options);
      > > >
      > >
      >
    • focus2friends
      Ok, the borders of TaffyDB are now clear. I ll finish my client data broker app, see what I come across and share my thoughts. cheers.
      Message 2 of 7 , Nov 24, 2008
      • 0 Attachment
        Ok, the "borders" of TaffyDB are now clear. I'll finish my "client data broker" app, see what
        I come across and share my thoughts.

        cheers.

        --- In taffydb@yahoogroups.com, "tacoman_cool" <ian@...> wrote:
        >
        > It very much would. The reason it hasn't to date is to save space in
        > the .js file and to focus on the API more on the things people have
        > been asking for. Personally I'd like to look at returning an special
        > object from get() that would be able to do this type of thing.
        >
        > So you could do:
        > collection.get({addressState:"WA"}).getUniques("somecolumn");
        >
        > or, as in our other discussion:
        >
        > collection.get({addressState:"WA"}).subSelect(["col1","col2");
        >
        > Any thoughts?
        >
        > --- In taffydb@yahoogroups.com, "focus2friends" <focus2friends@> wrote:
        > >
        > > Wouldn't it be easier if you could select a specified field (column)
        > values from the
        > > collection and do a gatherUnique on that resultset?
        > >
        > > --- In taffydb@yahoogroups.com, "tacoman_cool" <ian@> wrote:
        > > >
        > > > The way to do that is using the Taffy Utility function
        > > > TAFFY.gatherUniques.
        > > >
        > > > You'll need to build a bit of a wrapper though. Something like:
        > > >
        > > > optionsDB.getOptGroups = function () {
        > > > var x = [];
        > > > optionsDB.forEach(function (r) {x[x.length] = r.optgroup});
        > > > return TAFFY.gatherUniques(x);
        > > > }
        > > >
        > > > That should return an array of unique values.
        > > >
        > > > --- In taffydb@yahoogroups.com, "focus2friends" <focus2friends@>
        > wrote:
        > > > >
        > > > > I've a Taffy collection where each row contains 2 fields (see
        > > > snippet below). Now I want to
        > > > > retrieve the unique values of the "optgroup" field, so the resultset
        > > > should contain "Tires",
        > > > > "Color" and "Interior".
        > > > >
        > > > > What's the easiest way to do this with Taffy?
        > > > >
        > > > >
        > > > >
        > > > >
        > > > > var options = [
        > > > > {"optname":"195SR14", "optgroup":"Tires"},
        > > > > {"optname":"185SR13", "optgroup":"Tires"},
        > > > > {"optname":"180SR14", "optgroup":"Tires"},
        > > > > {"optname":"Blue", "optgroup":"Color"},
        > > > > {"optname":"Red", "optgroup":"Color"},
        > > > > {"optname":"Black", "optgroup":"Color"},
        > > > > {"optname":"Silver", "optgroup":"Color"},
        > > > > {"optname":"Green", "optgroup":"Color"},
        > > > > {"optname":"Leather", "optgroup":"Interior"},
        > > > > {"optname":"Vinyl", "optgroup":"Interior"}
        > > > > ];
        > > > >
        > > > > var optionsDB = new TAFFY(options);
        > > > >
        > > >
        > >
        >
      • martin_seidel
        ... Actually, a function to get only unique values out of a TAFFY would have been convenient for my mini-catalogue app too, but gatherUniques(array) is also
        Message 3 of 7 , Dec 14, 2008
        • 0 Attachment
          --- In taffydb@yahoogroups.com, "tacoman_cool" <ian@...> wrote:
          >
          > It very much would. The reason it hasn't to date is to save space in
          > the .js file and to focus on the API more on the things people have
          > been asking for. Personally I'd like to look at returning an special
          > object from get() that would be able to do this type of thing.
          >
          > So you could do:
          > collection.get({addressState:"WA"}).getUniques("somecolumn");
          >
          > or, as in our other discussion:
          >
          > collection.get({addressState:"WA"}).subSelect(["col1","col2");
          >
          > Any thoughts?
          >
          Actually, a function to get only unique values out of a TAFFY would
          have been convenient for my mini-catalogue app too, but
          gatherUniques(array) is also useful.
        • martin_seidel
          Great work, btw.
          Message 4 of 7 , Dec 14, 2008
          • 0 Attachment
            Great work, btw.
          Your message has been successfully submitted and would be delivered to recipients shortly.