最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to declare a sequelize-auto in nodejs program? - Stack Overflow

programmeradmin4浏览0评论

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 ().

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._pile (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

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./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._pile (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
Share Improve this question asked Dec 30, 2015 at 8:11 SakthiSureshAnandSakthiSureshAnand 1,3621 gold badge19 silver badges35 bronze badges
Add a ment  | 

5 Answers 5

Reset to default 4

I am using grunt to run this mand. I was getting the same error when I was running grunt schema mand. It got resolved by installing sequelize-auto globally: npm install -g sequelize-auto

Hope this was helpful.

You must run mand 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.

You must enable PowerShell scripts execution .

For details see:

https://windowsloop./enable-powershell-scripts-execution-windows-10/

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);
});

you must install sequelize-auto and mysql2 globally then run mand (sequelize-auto -o "./models" -d sequelize_auto_test -h localhost -u my_username -p 5432 -x my_password -e postgres)

发布评论

评论列表(0)

  1. 暂无评论