Created
September 29, 2012 11:53
-
-
Save pjsvis/3803788 to your computer and use it in GitHub Desktop.
Module for Could Persistence in MongoLab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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