Client side JavaScript client side framework?

I’m a little tired of using JSON / Rest services recently and manually typing methods on the server that perform basic CRUD operations in the database.

What I would like to do is in javascript (ajax based applications) do something like form

var allStudents = students.getAllStudents(); // returns all items of the students table var student = new student(); student.name = "Joe"; student.address = "123 Sesame st"; students.add(student); // commits it to the students table var student = students.getStudentById(57); 

Now, like any ORM, all these methods will be automated / written for me.

Also note that I'm not saying that Javascript should talk directly to the database. This is still done by Restful calls (backstage on the server). But I just want these gross operations to be automated and transparent to me, so I don’t need to manually write them on the server.

Do you guys know any framework that would help achieve this?

My main backend is Java / Spring3MVC. But I would also like to hear ideas that Node.js can possibly use.

+4
source share
3 answers

I'm not sure how much this saves time than just writing AJAX RESTful queries, but the Dojo JsonRest store is one of the solutions I have seen that works similar to what you are describing. Personally, I find it more readable to write an ajax request explicitly, but if you don't mind sticking to Dojo's philosophy of how your requests should be structured, you might like this. Anyway, here is the code from this documentation page:

 require(["dojo/store/JsonRest"], function(JsonRestStore){ var store = new JsonRestStore({target: "/Table/" }); store.get(3).then(function(object){ // use the object with the identity of 3 }); store.query("foo=bar").then(function(results){ // use the query results returned from the server }); store.put({ foo: "bar" }, { id: 3 }); // store the object with the given identity store.remove(3); // delete the object }); 
+2
source

If you can use something like Backbone.js or Can.js (recommended) for your interfaces and without any problems interact with your database through RESTfull services in such a way that you will be impressed if you have not seen it before.

http://backbonejs.org/ http://canjs.us/

Both use an MVC framework that is incredibly easy to set up. Take a look at the demos and examples.

0
source

Looking for the same thing, I came across sproutcore records . Sounds like an orm solution for javascript.

0
source

All Articles