diff --git a/moonridge.js b/moonridge.js index 016c381..9cb3e01 100644 --- a/moonridge.js +++ b/moonridge.js @@ -52,6 +52,7 @@ function connect (connString, opts) { function regNewModel (name, schema, opts) { var model = MRModel.apply(moonridgeSingleton, arguments) models[name] = model + model.controller = baucis.rest(name) return model } @@ -70,7 +71,7 @@ function registerUserModel (schemaExtend, opts) { _.extend(userSchema, schemaExtend) userModel = MRModel.call(moonridgeSingleton, 'user', userSchema, opts) models['user'] = userModel - + userModel.controller = baucis.rest('user') return userModel } @@ -89,7 +90,6 @@ function bootstrap () { Object.keys(models).forEach(function (modelName) { var model = models[modelName] - baucis.rest(modelName) model._exposeCallback(server) }) diff --git a/package.json b/package.json index 68ef282..3fa2d9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moonridge", - "version": "0.9.27", + "version": "0.9.28", "main": "moonridge.js", "author": "Capaj ", "description": "Isomorphic library, which allows you to use Mongoose.js models via socket.io-rpc doing regular queries and liveQueries", @@ -41,7 +41,7 @@ "baucis-swagger": "^1.1.2", "debug": "^2.2.0", "lodash": "^3.10", - "mongoose": "^4.4.2", + "mongoose": "^4.4.4", "mongoose-schema-serializer": "^1.0.1", "socket.io-rpc": "^1.1.3" }, diff --git a/test/model.spec.js b/test/model.spec.js index 818755a..686439d 100644 --- a/test/model.spec.js +++ b/test/model.spec.js @@ -9,6 +9,18 @@ describe('Moonridge model', function () { let server let LQ + it('should have a baucis controller', function () { + sampleModel = MR.model('first_test_model', { + name: String + }) + const ctrl = sampleModel.controller + expect(ctrl).to.be.a('function') + expect(ctrl.put).to.be.a('function') + expect(ctrl.get).to.be.a('function') + expect(ctrl.delete).to.be.a('function') + expect(ctrl.post).to.be.a('function') + }) + it('should run schemaInit on registering a new model', function (done) { sampleModel = MR.model('sample_model', { name: String