Reputation: 1362
When I am declaring a sequelize-auto
in my program I'm getting an error like o is not defined
.I tried so many ways to rectify this problem but it doesn't work.I referred this link (https://github.com/sequelize/sequelize-auto).
My Code is
var Sequelizeauto = require('sequelize-auto');
var tableCreatin = new Sequelizeauto -o [modelPath] -d <loginform> -h <localhost> -u <root> -p <3306> -x <root> -e [mysql];
Error
ReferenceError: o is not defined
at Object.<anonymous> (D:\NodeProject\Sequeliser\server.js:23:39)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
at startup (node.js:118:18)
at node.js:952:3
Upvotes: 0
Views: 5425
Reputation: 1
you must install sequelize-auto and mysql2 globally then run command (sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres)
Upvotes: 0
Reputation: 425
for anyone arriving here after all these years - this actually (at least now) can be done, and in a very straightforward way. as can be found in their sample
const SequelizeAuto = require('sequelize-auto');
const output = "./models";
const options = { directory: output, caseFile: 'l', caseModel: 'p', caseProp: 'c', lang: 'js', useDefine: false, singularize: true, spaces: true, indentation: 2 };
const config = {
dialect: '...',
host: "...",
port: ...,
dbname: "...",
user: "...",
pass: "...",
...options
};
var auto = new SequelizeAuto(config.dbname, config.user, config.pass, config);
auto.run().then(data => {
const tableNames = Object.keys(data.tables);
console.log(tableNames);
});
Upvotes: 0
Reputation: 1
You must enable PowerShell scripts execution .
For details see:
https://windowsloop.com/enable-powershell-scripts-execution-windows-10/
Upvotes: 0
Reputation: 3627
I am using grunt to run this command. I was getting the same error when I was running grunt schema command. It got resolved by installing sequelize-auto globally: npm install -g sequelize-auto
Hope this was helpful.
Upvotes: 4
Reputation: 12033
You must run command sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres
in termintal, its not a JS code.
Upvotes: 2