1.0.0 • Published 2 years ago

tunneled-sequelize-auto v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

tunneled-sequelize-auto

Console tool for generating sequelize models for working with database

It was originally created to work with the database of the Bitrix framework

You need to disable skip-name-resolve property in your MySQL config. For BitrixVM it located in /etc/my.cnf

Allows you to connect to a remote database via ssh tunnel and create the models and types (for typescript) with one command

It also allows you to connect to the database directly, for this you need to skip the ssh* parameters

ParameterRequired
langNo (es5, es6 (default), esm, ts)
sshUserYes
sshHostYes
sshPassYes
sshPortNo (22 is default)
dbUserNo ("bitrix0" default)
dbPassYes
dbNameNo ("sitemanager" default)
dbHostNo ("localhost" default)
dbPortNo (3306 default)
pathNo ("./src/models" default)

Example: npx tunneled-sequelize-auto --sshUser=bitrix --sshPass=asinfi235ion --sshHost=192.168.0.113 --dbPass="sdsada" --lang=ts --path="./backend/models

To import all models, you need to call initModels function

import {initModels} from "./models/initModels";
...
const models = initModels(sequelize);
models.User.findAll({ where: { username: "tony" }}).then(...);

or you can use each model separately