Update and remove operation on Jaydata

I'm trying to write a simple CRUD functionality in Jaydata, I had written this simple code for update operation:

SampleClass.prototype.Load = function(input1,callback)
{
  var param='it.Name=="'+input1+'"';
  this.data.items.filter(param).forEach(function(ii)
    {
      callback(ii);
    });
  this.data.items.saveChanges();
};

so when I call:

t.Load('Entry4',function(res){console.log(res.Name)})

It works like a charm! But If I call an update operation for callback like:

t.Load('Entry4',function(res){res.Name="Entry5"})

It doesn't change anything in the DB. I have seen something like beginTransaction function as in http://jaydata.org/examples/JayDataPro/ToDoList_complex, but I couldn't understand the essence of it.

Answers


Special thanks to Gabor Dolla

In order to update a value in JayData:

  • DB has to have a primary-key inside it.
  • Change non-key attributes
  • Call the asynchronous save() function after it.

solution to the question is: after changing the object field's definition like this:

Name{ type:'string', **key:true**}

You can query on anything but only change non-key attributes of them

t.Load('Entry4',function(res){res.LastName="Entry5";res.save()});

Need Your Help

Unable to reference to uhd(USRP)

g++ ubuntu-12.04 gnuradio uhd

There is some linker issue while compiling a cpp program

Issue while enabling hyperlinks in master page from content page

c# asp.net

I had written code to Enable and disable hyperlinks on master page from the content page. Every thing is working fine and the hyperlinks are getting disabled also after calling the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.