PODSTAWY BAZ DANYCH

Podstawy baz danych 12

Sequelize

Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication and more.

Materiały

V5

V6

sequelize-cli

mkdir project_name
cd project_name

npm init # (7/8x enter)
npm install sequelize --save
npm install sequelize-cli --save-dev
npx sequelize init

# edit config/config.json
# ustawic haslo/port/host/username/dialect dla bazy danych
# https://sequelize.org/master/manual/dialect-specific-things.html#underlying-connector-libraries
# https://sequelize.org/master/manual/migrations.html

npx sequelize db:drop
npx sequelize db:create
npx sequelize model:generate --name User --attributes email:string firstName:string lastName:string admin:boolean age:integer

Tips and tricks