Skip to content

Instantly share code, notes, and snippets.

@pjsvis
Created September 29, 2012 11:53
Show Gist options
  • Save pjsvis/3803788 to your computer and use it in GitHub Desktop.
Save pjsvis/3803788 to your computer and use it in GitHub Desktop.
Module for Could Persistence in MongoLab
// This is a module for cloud persistance 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;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment