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

Re: [taffydb] Re: stringify

Expand Messages
  • Rory Barrett
    Hello Colleagues I am not familar with JSON. If I need it then I will learn about it. Right now all I want to be able to do is be able to turn the different
    Message 1 of 7 , Dec 21, 2009
    • 0 Attachment
      Hello Colleagues
       
      I am not  familar with JSON. If I need it then I will learn about it. Right now all I want to be able to do is be able to turn the different fields in the records in a collection into strings which can be used in a javascript program.
       
      What I mean is this. Assuming you had a really simple collection like
      var mycollection = TAFFY([
      [{F1:"Amy",F2: "Palmer"} ,{F1:""Bob" ,F2:"Smith" }]
      ])
      and suppose you needed the F2s as strings then how do you get this ?
       
      I am sorry to ask questions about something that probably seems really basic and pointless however if Taffy offers a way of getting persistence simply then all my computing problems are solved.
       
      My current situation is that I have very good javascript programs that generate values as strings. The problem is that when I turn the computerr off these values cease to exist. What I need is for them to be retained. I thought that Taffy was a way I could do this. I expect that it is but I need to be able to turn records into arrays of strings which can be used in a javascript program. Is anyone able to help without referring to JSON which I know little about and seems somewhat complicated.
       
      Rory Barrett

      ----- Original Message -----
      Sent: Monday, December 21, 2009 4:50 PM
      Subject: [taffydb] Re: stringify

       

      Hi Rory,

      Let's back up a second. If you have some data you can create a Taffy collection as follows:

      var mycollection = TAFFY([
      [{F1:"Amy",F2: "Palmer"} ,{F1:""Bob" ,F2:"Smith" }]
      ])

      Now you can do a lot.

      mycollection. stringify( ) will turn all your data into a JSON packet that you can print to the string, pass back to the server, etc. Example:

      alert(mycollection. stringify( ));

      If you want just the first record you can get it like this:

      mycollection. first();

      This returns the record itself. So this should alert "Amy":

      alert(mycollection. first().F1) ;

      If you want the first record where F2 is "Smith" you can do this. It will alert Bob:

      alert(mycollection. first({F2: "Smith"}) .F1);

      I hope that helps,

      Ian

      --- In taffydb@yahoogroups .com, "Rory Barrett" <ramses@...> wrote:
      >
      > Hello fellow Taffy Users
      >
      > I have only just begun using Taffy and have encountered a problem that someone can possibly help with.
      >
      > Suppose you have a collection consisting of 5 records called coll. Each record has 4 fields say F1,F2,F3, F4.
      >
      > If I declare an array called myColl = coll.stringify( );
      > do I get a string array myColl so if I use myColl[3][2] I get a string which is the string version of the second field of the third record ?
      >
      > I have assumed this to be the case but have been informed by the page I have been working on there are errors.
      >
      > I really need the string version of the second field of the third record and similar. If I can't get it using stringify then how do I do so and how does stringify() work ?
      >
      > Rory Barrett
      >

    • tacoman_cool
      You ve hit the nail on the head :-) You can t persist values in JavaScript without either using browser features (somewhat iffy) or having a server somewhere
      Message 2 of 7 , Dec 21, 2009
      • 0 Attachment
        You've hit the nail on the head :-) You can't persist values in JavaScript without either using browser features (somewhat iffy) or having a server somewhere to pass data to and have that data written to a database.

        For a server you'll be using Ajax, for trying to save data to the browser I can reccomend playing around with http://pablotron.org/software/persist-js/

        As a side note, there is no limit on size of objects or number of records. However once you get over 4 or 5 thousands records things start to slow down depending on how you use Taffy. I have seen collections as big as 50K though.

        --- In taffydb@yahoogroups.com, "Rory Barrett" <ramses@...> wrote:
        >
        > Hello Colleagues
        >
        > I am not familar with JSON. If I need it then I will learn about it. Right now all I want to be able to do is be able to turn the different fields in the records in a collection into strings which can be used in a javascript program.
        >
        > What I mean is this. Assuming you had a really simple collection like
        > var mycollection = TAFFY([
        > [{F1:"Amy",F2:"Palmer"},{F1:""Bob",F2:"Smith"}]
        > ])
        > and suppose you needed the F2s as strings then how do you get this ?
        >
        > I am sorry to ask questions about something that probably seems really basic and pointless however if Taffy offers a way of getting persistence simply then all my computing problems are solved.
        >
        > My current situation is that I have very good javascript programs that generate values as strings. The problem is that when I turn the computerr off these values cease to exist. What I need is for them to be retained. I thought that Taffy was a way I could do this. I expect that it is but I need to be able to turn records into arrays of strings which can be used in a javascript program. Is anyone able to help without referring to JSON which I know little about and seems somewhat complicated.
        >
        > Rory Barrett
        >
        >
        > ----- Original Message -----
        > From: tacoman_cool
        > To: taffydb@yahoogroups.com
        > Sent: Monday, December 21, 2009 4:50 PM
        > Subject: [taffydb] Re: stringify
        >
        >
        >
        > Hi Rory,
        >
        > Let's back up a second. If you have some data you can create a Taffy collection as follows:
        >
        > var mycollection = TAFFY([
        > [{F1:"Amy",F2:"Palmer"},{F1:""Bob",F2:"Smith"}]
        > ])
        >
        > Now you can do a lot.
        >
        > mycollection.stringify() will turn all your data into a JSON packet that you can print to the string, pass back to the server, etc. Example:
        >
        > alert(mycollection.stringify());
        >
        > If you want just the first record you can get it like this:
        >
        > mycollection.first();
        >
        > This returns the record itself. So this should alert "Amy":
        >
        > alert(mycollection.first().F1);
        >
        > If you want the first record where F2 is "Smith" you can do this. It will alert Bob:
        >
        > alert(mycollection.first({F2:"Smith"}).F1);
        >
        > I hope that helps,
        >
        > Ian
        >
        > --- In taffydb@yahoogroups.com, "Rory Barrett" <ramses@> wrote:
        > >
        > > Hello fellow Taffy Users
        > >
        > > I have only just begun using Taffy and have encountered a problem that someone can possibly help with.
        > >
        > > Suppose you have a collection consisting of 5 records called coll. Each record has 4 fields say F1,F2,F3, F4.
        > >
        > > If I declare an array called myColl = coll.stringify();
        > > do I get a string array myColl so if I use myColl[3][2] I get a string which is the string version of the second field of the third record ?
        > >
        > > I have assumed this to be the case but have been informed by the page I have been working on there are errors.
        > >
        > > I really need the string version of the second field of the third record and similar. If I can't get it using stringify then how do I do so and how does stringify() work ?
        > >
        > > Rory Barrett
        > >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.