I'm starting out with node.js and sequelize and I get the following error:
/home/cbaket/test/test.js:9
.complete(function(err) {
^
TypeError: undefined is not a function
at Object.<anonymous> (/home/cbaket/test/test.js:9:6)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
My file: test.js is:
var Sequelize = require('sequelize');
var sequelize = new Sequelize('apidb', 'apidb', 'apidb', {
dialect: "mysql", // or 'sqlite', mysql', 'mariadb'
port: 3306 // or 5432 (for postgres)
});
sequelize
.authenticate()
.complete(function(err) {
if (!!err) {
console.log('Unable to connect to the database:', err)
} else {
console.log('Connection has been established successfully.')
}
});
I'm following one of the early tutorials on the Sequelieze website.
I installed the latest sequelize and mysql with the following command.
$ npm install mysql
$ npm install sequelize
I have tried a lot of similar examples and always get the same error. The libraries are working because other examples work fine, i could create tables in the database and get data from it but the authenticate function always fails.
Thanks! ;)