Mongoose Mixed Schema not working

I am trying to set mixed Schema in ExpressJs I tried to use mongoose.Schema.Types.Mixed didn´t worked and tried explicit as shown bellow but unfortunately it fails with same error:

"C:\Program Files (x86)\JetBrains\WebStorm 9.0.3\bin\runnerw.exe" "C:\Program Files (x86)\nodejs\node.exe" app.js

c:\Users\User\Desktop\nodekid\node_modules\node-restful\lib\model.js:247 app.getDetail = app.get; ^ TypeError: Cannot read property 'get' of undefined at Function.Model.register (c:\Users\User\Desktop\nodekid\node_modules\node-restful\lib\model.js:247:22) at Object. (c:\Users\User\Desktop\nodekid\routes\api.js:10:8) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (c:\Users\User\Desktop\nodekid\app.js:18:17) at Module._compile (module.js:456:26)

Process finished with exit code 8

/**
 * Created by User on 3/8/2015.
 */
var  restful = require("node-restful");

var mongoose = restful.mongoose;

var storeSchema = new  mongoose.Schema({
   name: String,
   products: [new mongoose.Schema({
      name : String,
      description : String
   })]

});
module.exports = restful.model("store", storeSchema);


/**
 * Created by User on 3/8/2015.
 */
var express = require("express");

var router = express().Router;

var stores = require ("../models/store");
stores.methods(["get","post","put","delete"]);
stores.register(router,"stores");

module.exports = router;

New Error:

c:\Users\User\Desktop\nodekid\node_modules\node-restful\lib\model.js:228 app[key](prefix + '/:id([0-9a-fA-F]{0,24}$)?', handlerlist); ^ TypeError: Object function createApplication() { var app = function(req, res, next) { app.handle(req, res, next); };

mixin(app, EventEmitter.prototype, false); mixin(app, proto, false);

app.request = { proto: req, app: app }; app.response = { proto: res, app: app }; app.init(); return app; } has no method 'get' at Function.Model.registerRoutes (c:\Users\User\Desktop\nodekid\node_modules\node-restful\lib\model.js:228:17) at Function.Model.register (c:\Users\User\Desktop\nodekid\node_modules\node-restful\lib\model.js:248:8) at Object. (c:\Users\User\Desktop\nodekid\routes\api.js:10:8) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at Object. (c:\Users\User\Desktop\nodekid\app.js:18:17)

Upvotes: 0

Views: 672

Answers (1)

The error was in api.js in setting routing:

var router = express().Router;

Just Change it with:

var router = express.Router();

Upvotes: 0

Related Questions