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

v2.0 OrberBy() and Get() are missing

Expand Messages
  • Givius
    Hello, I just got the update from 1.7 to 2.0, and now my code is complaining about this two functions: taffyObj.orderBy is not a function taffyObj.get is
    Message 1 of 3 , Sep 8, 2011
    • 0 Attachment
      Hello,

      I just got the update from 1.7 to 2.0, and now my code is complaining about this two functions:
      "taffyObj.orderBy is not a function"
      "taffyObj.get is not a function"

      can you please advice how can I handle this two missing/changed functions.

      thanks

      -Charly
    • tacoman_cool
      Hi Charly, There are a couple of key API differences between the 1.X stack and 2.0. The main one is that your DB is now a function and you use that function to
      Message 2 of 3 , Sep 8, 2011
      • 0 Attachment
        Hi Charly,

        There are a couple of key API differences between the 1.X stack and 2.0. The main one is that your DB is now a function and you use that function to filter for records. It returns a collection of methods to then work with your filtered data.

        So...

        var mystuff = TAFFY();

        // get records with status = 1
        var myrecords = mystuff({status:1}).get();

        Additionally the root DB function has a couple of methods:

        mystuff.insert(newrecord);
        mystuff.sort("status desc");

        Sort changes the order of the data in the database but it isn't the only way can order data. You can also do it when you query for data and using the order() method only changes the order of the data you are working with, not the whole DB.

        var myOrderedRecords = mystuff({status:1}).order("name").get();

        There are a variety of reasons for the change but one key advantage is chaining of methods and reuse of queries.

        Example chain:

        mystuff().limit(15).order("name").each(func).update();

        Example reuse:

        var activeRecords = mystuff({status:1});

        activeRecords.get();
        activeRecords.each();
        activeRecords.update();

        So you'll have to make a few minor updates to your code. The docs on TaffyDB.com have been updated to reflect the changes.

        Ian

        --- In taffydb@yahoogroups.com, "Givius" <givius24@...> wrote:
        >
        > Hello,
        >
        > I just got the update from 1.7 to 2.0, and now my code is complaining about this two functions:
        > "taffyObj.orderBy is not a function"
        > "taffyObj.get is not a function"
        >
        > can you please advice how can I handle this two missing/changed functions.
        >
        > thanks
        >
        > -Charly
        >
      • Givius
        Thanks a lot for the advice I did the changes in my code and all seems to be working fine. --Charles
        Message 3 of 3 , Sep 14, 2011
        • 0 Attachment
          Thanks a lot for the advice I did the changes in my code and all seems to be working fine.

          --Charles

          --- In taffydb@yahoogroups.com, "tacoman_cool" <ian@...> wrote:
          >
          > Hi Charly,
          >
          > There are a couple of key API differences between the 1.X stack and 2.0. The main one is that your DB is now a function and you use that function to filter for records. It returns a collection of methods to then work with your filtered data.
          >
          > So...
          >
          > var mystuff = TAFFY();
          >
          > // get records with status = 1
          > var myrecords = mystuff({status:1}).get();
          >
          > Additionally the root DB function has a couple of methods:
          >
          > mystuff.insert(newrecord);
          > mystuff.sort("status desc");
          >
          > Sort changes the order of the data in the database but it isn't the only way can order data. You can also do it when you query for data and using the order() method only changes the order of the data you are working with, not the whole DB.
          >
          > var myOrderedRecords = mystuff({status:1}).order("name").get();
          >
          > There are a variety of reasons for the change but one key advantage is chaining of methods and reuse of queries.
          >
          > Example chain:
          >
          > mystuff().limit(15).order("name").each(func).update();
          >
          > Example reuse:
          >
          > var activeRecords = mystuff({status:1});
          >
          > activeRecords.get();
          > activeRecords.each();
          > activeRecords.update();
          >
          > So you'll have to make a few minor updates to your code. The docs on TaffyDB.com have been updated to reflect the changes.
          >
          > Ian
          >
          > --- In taffydb@yahoogroups.com, "Givius" <givius24@> wrote:
          > >
          > > Hello,
          > >
          > > I just got the update from 1.7 to 2.0, and now my code is complaining about this two functions:
          > > "taffyObj.orderBy is not a function"
          > > "taffyObj.get is not a function"
          > >
          > > can you please advice how can I handle this two missing/changed functions.
          > >
          > > thanks
          > >
          > > -Charly
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.