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

Ruby On Rails: Active Recode method Save is undefined when called in Link Controller,

activerecord methods ruby-on-rails-3.1 save undefined

I', working on a Ruby On Rails App, and I am getting the following error when I attempt to call the Save method from Active Record to populate a new link to the database. This is code that goes wro...

Reading the local password policy programmatically

windows security winapi

Are there Windows API functions that allows reading what the current password policy is? For instance, minimum length, complexity etc.

How to limit number of rows returned from Oracle at the JDBC data source level?

java sql oracle jdbc jndi

Is there a way to limit the rows returned at the Oracle datasource level in a Tomcat application?

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.