diff --git a/lib/database.js b/lib/database.js index b6c17f9..ad30031 100644 --- a/lib/database.js +++ b/lib/database.js @@ -35,6 +35,7 @@ var Document = require("./document"); // database extends backbone collection Database.prototype = Object.create(Backbone.Collection.prototype); +Database.extend = Backbone.Collection.extend; // database class extends document _.extend(Database.prototype, { diff --git a/test/test.js b/test/test.js index c520381..18e9765 100644 --- a/test/test.js +++ b/test/test.js @@ -21,6 +21,12 @@ describe("Documents", function() { expect(doc.isNew()).to.not.be.ok; }); + it("can create subclass from Document class", function() { + var subclass = Lazybones.Document.extend({ foo: function() {} }); + expect(subclass.prototype.foo).to.be.a.function; + expect(subclass.prototype.get).to.be.a.function; + }); + }); describe("Database", function() { @@ -41,6 +47,12 @@ describe("Database", function() { db.destroy().then(function() { done(); }, done); }); + it("can create subclass from Database class", function() { + var subclass = Lazybones.extend({ foo: function() {} }); + expect(subclass.prototype.foo).to.be.a.function; + expect(subclass.prototype.get).to.be.a.function; + }); + }); describe("CRUD", function() {