Last active
August 29, 2015 13:56
-
-
Save bendrucker/9274656 to your computer and use it in GitHub Desktop.
Default columns with a bookshelf collection
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
var ModelBase = Bookshelf.Model.extend(); | |
var CollectionBase = Bookshelf.Collection.extend({ | |
toJSON: function () { | |
var json = Bookshelf.Collection.toJSON.apply(this, arguments); | |
json.object = this.model.prototype.object; | |
return json; | |
}); | |
}); | |
Model.collection = function (models, options) { | |
return new CollectionBase(models || [], _.extend(options, {model: this})); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment