totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

Problem with new MODEL #554

Closed maxxam11 closed 7 years ago

maxxam11 commented 7 years ago

Hello. I update totaljs to last version and there was a new error when create new model:

var model = new MODEL('test').model();

error:
500: Internal Server ErrorTypeError: (name) => F.model(name) is not a constructor

Model code:

var mongoose = require('mongoose');

var schema = mongoose.Schema({ 
    id: Number,
    name: String,
});

var model = mongoose.model('tests', schema);

exports.model = model;
exports.name = 'test';

In previous version there is not this error.

petersirka commented 7 years ago

Hi @maxxam11, hmmm, there is arrow function and with MODEL() it doesn't work but with F.model() it works. Which version of Total.js was your previous?

petersirka commented 7 years ago

Can you test Total.js beta? Try: npm install total.js@beta --> it's stable.

maxxam11 commented 7 years ago

It's work without new: var model = MODEL('test').model(); Thanks. I will test with beta.