Sequelize: Unhandled rejection TypeError: Cannot read property 'id' of undefined
Currently using ExpressJS as the framework to create a small CMS system but currently running into a problem. I am trying to create a model for a table called 'roles' but when I add it to my database file to be included, I get the following error once I run 'node app.js'
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at Object.mapValueFieldNames (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibutils.js:232:19)
at Promise.try.then.then (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibmodel.js:2393:37)
at tryCatcher (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseutil.js:16:23)
at Promise._settlePromiseFromHandler (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:512:31)
at Promise._settlePromise (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:569:18)
at Promise._settlePromise0 (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:614:10)
at Promise._settlePromises (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:694:18)
at _drainQueueStep (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:138:12)
at _drainQueue (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:131:9)
at Async._drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:147:5)
at Immediate.Async.drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:17:14)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
If I do not include the model in the database init file, it runs just fine. The idea is to then use a relationship to pair the two. I do not plan on having permissions assigned, just using roles. The migration file is setup the same as the model. I was assuming by matching how the user model was setup, the roles model would work as well. But now I am unsure what is going on.
Users
'use strict';
const
Promise = require('bluebird'),
bcrypt = Promise.promisifyAll(require('bcrypt'))
;
module.exports = (sequelize, DataTypes) => {
const users = sequelize.define('users', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
username: {
type: DataTypes.STRING,
notEmpty: true,
unique: true
},
password: {
type: DataTypes.STRING,
notEmpty: true
},
role: {
type: DataTypes.INTEGER(2).UNSIGNED,
validate: {
isNumeric: true
}
},
steamid: {
type: DataTypes.STRING(17),
validate: {
len: 17
}
},
link: {
type: DataTypes.STRING,
validate: {
isUrl: true
}
},
last_login: DataTypes.DATE
},
{
hooks: {
beforeCreate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
},
beforeUpdate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
}
}
});
users.prototype.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(10));
};
users.prototype.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
};
users.sync({force: false}).then(() => {
return users.findOrCreate({
where: {
id: 1,
username: 'Admin'
},
defaults: {
username: 'Admin',
password: 'admin123',
role: 1,
steamid: parseInt(12345678901234567),
link: 'https://www.example.com/user_profile.php?userID=1171981'
}
});
});
return users;
};
Roles
'use strict';
module.exports = (sequelize, DataTypes) => {
const roles = sequelize.define('roles', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
name: DataTypes.STRING,
slug: DataTypes.STRING
}, {
timestamps: false
});
let role = ;
role.push([
{ name: 'Admin', slug: 'admin'},
{ name: 'Staff', slug: 'staff'},
{ name: 'Trainer', slug: 'trainer'},
{ name: 'Captain', slug: 'captain'},
{ name: 'Monkey', slug: 'monkey'}
]);
roles.sync({force: false}).then(() => {
return roles.bulkCreate(role);
});
return roles;
};
Init
const
config = require('../config/database'),
Sequelize = require('sequelize'),
sequelize = new Sequelize(config),
db = {}
;
db.Sequelize = Sequelize;
db.sequelize = sequelize;
db.users = require('./models/users')(sequelize, Sequelize);
db.roles = require('./models/roles')(sequelize, Sequelize);
module.exports = db;
mysql express sequelize.js
add a comment |
Currently using ExpressJS as the framework to create a small CMS system but currently running into a problem. I am trying to create a model for a table called 'roles' but when I add it to my database file to be included, I get the following error once I run 'node app.js'
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at Object.mapValueFieldNames (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibutils.js:232:19)
at Promise.try.then.then (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibmodel.js:2393:37)
at tryCatcher (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseutil.js:16:23)
at Promise._settlePromiseFromHandler (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:512:31)
at Promise._settlePromise (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:569:18)
at Promise._settlePromise0 (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:614:10)
at Promise._settlePromises (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:694:18)
at _drainQueueStep (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:138:12)
at _drainQueue (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:131:9)
at Async._drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:147:5)
at Immediate.Async.drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:17:14)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
If I do not include the model in the database init file, it runs just fine. The idea is to then use a relationship to pair the two. I do not plan on having permissions assigned, just using roles. The migration file is setup the same as the model. I was assuming by matching how the user model was setup, the roles model would work as well. But now I am unsure what is going on.
Users
'use strict';
const
Promise = require('bluebird'),
bcrypt = Promise.promisifyAll(require('bcrypt'))
;
module.exports = (sequelize, DataTypes) => {
const users = sequelize.define('users', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
username: {
type: DataTypes.STRING,
notEmpty: true,
unique: true
},
password: {
type: DataTypes.STRING,
notEmpty: true
},
role: {
type: DataTypes.INTEGER(2).UNSIGNED,
validate: {
isNumeric: true
}
},
steamid: {
type: DataTypes.STRING(17),
validate: {
len: 17
}
},
link: {
type: DataTypes.STRING,
validate: {
isUrl: true
}
},
last_login: DataTypes.DATE
},
{
hooks: {
beforeCreate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
},
beforeUpdate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
}
}
});
users.prototype.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(10));
};
users.prototype.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
};
users.sync({force: false}).then(() => {
return users.findOrCreate({
where: {
id: 1,
username: 'Admin'
},
defaults: {
username: 'Admin',
password: 'admin123',
role: 1,
steamid: parseInt(12345678901234567),
link: 'https://www.example.com/user_profile.php?userID=1171981'
}
});
});
return users;
};
Roles
'use strict';
module.exports = (sequelize, DataTypes) => {
const roles = sequelize.define('roles', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
name: DataTypes.STRING,
slug: DataTypes.STRING
}, {
timestamps: false
});
let role = ;
role.push([
{ name: 'Admin', slug: 'admin'},
{ name: 'Staff', slug: 'staff'},
{ name: 'Trainer', slug: 'trainer'},
{ name: 'Captain', slug: 'captain'},
{ name: 'Monkey', slug: 'monkey'}
]);
roles.sync({force: false}).then(() => {
return roles.bulkCreate(role);
});
return roles;
};
Init
const
config = require('../config/database'),
Sequelize = require('sequelize'),
sequelize = new Sequelize(config),
db = {}
;
db.Sequelize = Sequelize;
db.sequelize = sequelize;
db.users = require('./models/users')(sequelize, Sequelize);
db.roles = require('./models/roles')(sequelize, Sequelize);
module.exports = db;
mysql express sequelize.js
There should ne raw query above this error , please check that , and also post that over here.
– Vivek Doshi
Nov 20 '18 at 5:40
@VivekDoshi The only raw query I have is in the user controller.sequelize.query('SELECT users.*, Roles.* FROM users LEFT JOIN Roles ON users.role = Roles.id', { type: sequelize.QueryTypes.SELECT } ).then(users => { res.render('user/index', { users: users, csrf: req.csrfToken(), moment: moment, hasRole: hasRole, user: req.user }); });
– Ryahn
Nov 20 '18 at 7:03
add a comment |
Currently using ExpressJS as the framework to create a small CMS system but currently running into a problem. I am trying to create a model for a table called 'roles' but when I add it to my database file to be included, I get the following error once I run 'node app.js'
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at Object.mapValueFieldNames (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibutils.js:232:19)
at Promise.try.then.then (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibmodel.js:2393:37)
at tryCatcher (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseutil.js:16:23)
at Promise._settlePromiseFromHandler (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:512:31)
at Promise._settlePromise (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:569:18)
at Promise._settlePromise0 (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:614:10)
at Promise._settlePromises (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:694:18)
at _drainQueueStep (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:138:12)
at _drainQueue (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:131:9)
at Async._drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:147:5)
at Immediate.Async.drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:17:14)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
If I do not include the model in the database init file, it runs just fine. The idea is to then use a relationship to pair the two. I do not plan on having permissions assigned, just using roles. The migration file is setup the same as the model. I was assuming by matching how the user model was setup, the roles model would work as well. But now I am unsure what is going on.
Users
'use strict';
const
Promise = require('bluebird'),
bcrypt = Promise.promisifyAll(require('bcrypt'))
;
module.exports = (sequelize, DataTypes) => {
const users = sequelize.define('users', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
username: {
type: DataTypes.STRING,
notEmpty: true,
unique: true
},
password: {
type: DataTypes.STRING,
notEmpty: true
},
role: {
type: DataTypes.INTEGER(2).UNSIGNED,
validate: {
isNumeric: true
}
},
steamid: {
type: DataTypes.STRING(17),
validate: {
len: 17
}
},
link: {
type: DataTypes.STRING,
validate: {
isUrl: true
}
},
last_login: DataTypes.DATE
},
{
hooks: {
beforeCreate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
},
beforeUpdate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
}
}
});
users.prototype.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(10));
};
users.prototype.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
};
users.sync({force: false}).then(() => {
return users.findOrCreate({
where: {
id: 1,
username: 'Admin'
},
defaults: {
username: 'Admin',
password: 'admin123',
role: 1,
steamid: parseInt(12345678901234567),
link: 'https://www.example.com/user_profile.php?userID=1171981'
}
});
});
return users;
};
Roles
'use strict';
module.exports = (sequelize, DataTypes) => {
const roles = sequelize.define('roles', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
name: DataTypes.STRING,
slug: DataTypes.STRING
}, {
timestamps: false
});
let role = ;
role.push([
{ name: 'Admin', slug: 'admin'},
{ name: 'Staff', slug: 'staff'},
{ name: 'Trainer', slug: 'trainer'},
{ name: 'Captain', slug: 'captain'},
{ name: 'Monkey', slug: 'monkey'}
]);
roles.sync({force: false}).then(() => {
return roles.bulkCreate(role);
});
return roles;
};
Init
const
config = require('../config/database'),
Sequelize = require('sequelize'),
sequelize = new Sequelize(config),
db = {}
;
db.Sequelize = Sequelize;
db.sequelize = sequelize;
db.users = require('./models/users')(sequelize, Sequelize);
db.roles = require('./models/roles')(sequelize, Sequelize);
module.exports = db;
mysql express sequelize.js
Currently using ExpressJS as the framework to create a small CMS system but currently running into a problem. I am trying to create a model for a table called 'roles' but when I add it to my database file to be included, I get the following error once I run 'node app.js'
Unhandled rejection TypeError: Cannot read property 'id' of undefined
at Object.mapValueFieldNames (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibutils.js:232:19)
at Promise.try.then.then (C:UsersRyahnDocumentsProjectsmonkeysnode_modulessequelizelibmodel.js:2393:37)
at tryCatcher (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseutil.js:16:23)
at Promise._settlePromiseFromHandler (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:512:31)
at Promise._settlePromise (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:569:18)
at Promise._settlePromise0 (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:614:10)
at Promise._settlePromises (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleasepromise.js:694:18)
at _drainQueueStep (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:138:12)
at _drainQueue (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:131:9)
at Async._drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:147:5)
at Immediate.Async.drainQueues (C:UsersRyahnDocumentsProjectsmonkeysnode_modulesbluebirdjsreleaseasync.js:17:14)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
If I do not include the model in the database init file, it runs just fine. The idea is to then use a relationship to pair the two. I do not plan on having permissions assigned, just using roles. The migration file is setup the same as the model. I was assuming by matching how the user model was setup, the roles model would work as well. But now I am unsure what is going on.
Users
'use strict';
const
Promise = require('bluebird'),
bcrypt = Promise.promisifyAll(require('bcrypt'))
;
module.exports = (sequelize, DataTypes) => {
const users = sequelize.define('users', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
username: {
type: DataTypes.STRING,
notEmpty: true,
unique: true
},
password: {
type: DataTypes.STRING,
notEmpty: true
},
role: {
type: DataTypes.INTEGER(2).UNSIGNED,
validate: {
isNumeric: true
}
},
steamid: {
type: DataTypes.STRING(17),
validate: {
len: 17
}
},
link: {
type: DataTypes.STRING,
validate: {
isUrl: true
}
},
last_login: DataTypes.DATE
},
{
hooks: {
beforeCreate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
},
beforeUpdate: function(user, options) {
if (!user.changed('password')) {
return sequelize.Promise.reject('not modified');
}
return bcrypt.hash(user.password, 10).then(hash => {
return user.password = hash;
}).catch(err => {
return sequelize.Promise.reject(err);
});
}
}
});
users.prototype.generateHash = function(password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(10));
};
users.prototype.validPassword = function(password) {
return bcrypt.compareSync(password, this.password);
};
users.sync({force: false}).then(() => {
return users.findOrCreate({
where: {
id: 1,
username: 'Admin'
},
defaults: {
username: 'Admin',
password: 'admin123',
role: 1,
steamid: parseInt(12345678901234567),
link: 'https://www.example.com/user_profile.php?userID=1171981'
}
});
});
return users;
};
Roles
'use strict';
module.exports = (sequelize, DataTypes) => {
const roles = sequelize.define('roles', {
id: {
autoIncrement: true,
primaryKey: true,
type: DataTypes.INTEGER
},
name: DataTypes.STRING,
slug: DataTypes.STRING
}, {
timestamps: false
});
let role = ;
role.push([
{ name: 'Admin', slug: 'admin'},
{ name: 'Staff', slug: 'staff'},
{ name: 'Trainer', slug: 'trainer'},
{ name: 'Captain', slug: 'captain'},
{ name: 'Monkey', slug: 'monkey'}
]);
roles.sync({force: false}).then(() => {
return roles.bulkCreate(role);
});
return roles;
};
Init
const
config = require('../config/database'),
Sequelize = require('sequelize'),
sequelize = new Sequelize(config),
db = {}
;
db.Sequelize = Sequelize;
db.sequelize = sequelize;
db.users = require('./models/users')(sequelize, Sequelize);
db.roles = require('./models/roles')(sequelize, Sequelize);
module.exports = db;
mysql express sequelize.js
mysql express sequelize.js
asked Nov 20 '18 at 4:25
RyahnRyahn
195417
195417
There should ne raw query above this error , please check that , and also post that over here.
– Vivek Doshi
Nov 20 '18 at 5:40
@VivekDoshi The only raw query I have is in the user controller.sequelize.query('SELECT users.*, Roles.* FROM users LEFT JOIN Roles ON users.role = Roles.id', { type: sequelize.QueryTypes.SELECT } ).then(users => { res.render('user/index', { users: users, csrf: req.csrfToken(), moment: moment, hasRole: hasRole, user: req.user }); });
– Ryahn
Nov 20 '18 at 7:03
add a comment |
There should ne raw query above this error , please check that , and also post that over here.
– Vivek Doshi
Nov 20 '18 at 5:40
@VivekDoshi The only raw query I have is in the user controller.sequelize.query('SELECT users.*, Roles.* FROM users LEFT JOIN Roles ON users.role = Roles.id', { type: sequelize.QueryTypes.SELECT } ).then(users => { res.render('user/index', { users: users, csrf: req.csrfToken(), moment: moment, hasRole: hasRole, user: req.user }); });
– Ryahn
Nov 20 '18 at 7:03
There should ne raw query above this error , please check that , and also post that over here.
– Vivek Doshi
Nov 20 '18 at 5:40
There should ne raw query above this error , please check that , and also post that over here.
– Vivek Doshi
Nov 20 '18 at 5:40
@VivekDoshi The only raw query I have is in the user controller.
sequelize.query('SELECT users.*, Roles.* FROM users LEFT JOIN Roles ON users.role = Roles.id', { type: sequelize.QueryTypes.SELECT } ).then(users => { res.render('user/index', { users: users, csrf: req.csrfToken(), moment: moment, hasRole: hasRole, user: req.user }); });– Ryahn
Nov 20 '18 at 7:03
@VivekDoshi The only raw query I have is in the user controller.
sequelize.query('SELECT users.*, Roles.* FROM users LEFT JOIN Roles ON users.role = Roles.id', { type: sequelize.QueryTypes.SELECT } ).then(users => { res.render('user/index', { users: users, csrf: req.csrfToken(), moment: moment, hasRole: hasRole, user: req.user }); });– Ryahn
Nov 20 '18 at 7:03
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386207%2fsequelize-unhandled-rejection-typeerror-cannot-read-property-id-of-undefined%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386207%2fsequelize-unhandled-rejection-typeerror-cannot-read-property-id-of-undefined%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There should ne raw query above this error , please check that , and also post that over here.
– Vivek Doshi
Nov 20 '18 at 5:40
@VivekDoshi The only raw query I have is in the user controller.
sequelize.query('SELECT users.*, Roles.* FROM users LEFT JOIN Roles ON users.role = Roles.id', { type: sequelize.QueryTypes.SELECT } ).then(users => { res.render('user/index', { users: users, csrf: req.csrfToken(), moment: moment, hasRole: hasRole, user: req.user }); });– Ryahn
Nov 20 '18 at 7:03