-
-
Save kriszyp/752032 to your computer and use it in GitHub Desktop.
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
db = new Storage # external implementation | |
Store = (entity) -> | |
find: db.find.bind db, entity | |
get: db.get.bind db, entity | |
save: db.save.bind db, entity | |
add: db.insert.bind db, entity | |
remove: db.remove.bind db, entity | |
update: db.update.bind db, entity | |
patch: db.patch.bind db, entity | |
drop: db.drop.bind db, entity | |
Model = (entity, overrides) -> | |
Compose.create Store(entity), overrides | |
model = {} | |
model.Bar = Model 'Bar', | |
find: Compose.before (query) -> | |
[(query or '') + '&a!=null'] | |
foos: () -> @find "foo!=null" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
class Collection --->
var Collection; Collection = function() { function Collection(name) { this.foo = 'bar'; } Collection.prototype.method = function(args) { console.log(args); Collection.__super__.method.call(this, args); return this; }; return Collection; }();