Missing Account.findById
wtlin1228 opened this issue ยท 3 comments
wtlin1228 commented
There is no Account.findById
in the /server/models/account.js
.
So I can't transfer money between accounts.
Transfer works after I added the following code.
Account.findById = function (accountId) {
return Account.findOne({
where: { id: accountId },
attributes: ['id', 'userId', 'name', 'number', 'balance']
}).then(account => {
if (!account) throw new Error("No account found");
return account;
})
}
wtlin1228 commented
Maybe it's caused by upgrading sequelize to 5.21.7 from 5.21.6 in this commit.
RabeaGleissner commented
Thanks for that @wtlin1228 !
I just ran into the same issue and this fixed it ๐
dtauer commented
If anyone is still having issues with this, you can replace findById
with findByPk
. I also recommend using Node version 8.17.0
with this course.