Currently, I am developing a few Backbone applications that require Ruby on the backend for connecting to the database. However, I am exploring options to eliminate Ruby from my demos (although I understand this poses security risks in production).
Upon visiting the AngularJS website, I came across an interesting example (http://jsfiddle.net/api/post/library/pure/) where they connected directly to the Mongolabs service without the need for a backend language.
// This code snippet demonstrates cloud persistence in Mongolab - https://mongolab.com
angular.module('mongolab', ['ngResource']).
factory('Project', function($resource) {
var Project = $resource('https://api.mongolab.com/api/1/databases' +
'/angularjs/collections/projects/:id',
{ apiKey: '4f847ad3e4b08a2eed5f3b54' }, {
update: { method: 'PUT' }
}
);
Project.prototype.update = function(cb) {
return Project.update({id: this._id.$oid},
angular.extend({}, this, {_id:undefined}), cb);
};
Project.prototype.destroy = function(cb) {
return Project.remove({id: this._id.$oid}, cb);
};
return Project;
});
I'm curious if achieving a similar setup is possible in Backbone as well. If it is, could you guide me on how to do so? I attempted to study the approach used by AngularJS to replicate it, but I am still relatively new to Backbone and struggling to grasp their methodology.