Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2014 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/8368253 to your computer and use it in GitHub Desktop.
Save anonymous/8368253 to your computer and use it in GitHub Desktop.
innitApp.provider('Waterline',function(){
var _collections = []
var _adapters = {}
var waterline = new Waterline()
return {
$get : function(){
angular.forEach(_collections,function(_model){
waterline.loadCollection(_model)
})
console.log(_adapters)
waterline.initialize({adapters : _adapters},console.log.bind(console))
return waterline;
},
$adapter : function(adapter){
angular.extend(_adapters,adapter)
},
$collection : function(def){
_collections.push(Waterline.Collection.extend(def))
}
}
})
innitApp.config(['WaterlineProvider',function(WaterlineProvider){
//register an adapter w/ waterline provider
WaterlineProvider.$adapter({
foobar: {
identity: 'foobar',
foobar: function(collectionName, options, cb) {
return cb(null, {
status: true
});
}
}
})
//register an adapter w/ waterline provider
WaterlineProvider.$collection({
identity: 'cheesybread',
attributes: {},
adapter: 'foobar',
schema: false
})
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment