Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.49 KB

File metadata and controls

40 lines (31 loc) · 1.49 KB

is a promise-based Node.js ORM tool for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.

ORM = opject-relational mapper

Docs:

Multiple Eager Loading

querying for multiple tables:

Course_Events.findAll({ 
    include: [{ model: Sessions },
      { model: Course_Modules },
      { model: Teachers }]
    })

By default, Sequelize automatically adds the fields createdAt and updatedAt to every model, using the data type DataTypes.DATE. Apparently that causes errors if Sequelize is applied to a table without these fields. Remedy:

ALTER TABLE courses ADD createdAt TIMESTAMP NOT NULL
DEFAULT CURRENT_TIMESTAMP;

---and:
ALTER TABLE courses ADD updatedAt TIMESTAMP NOT NULL
DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP;

Use 'JOIN' in Sequelize

https://lorenstewart.me/2016/09/12/sequelize-table-associations-joins/

Might come in handy: https://grokonez.com/node-js/sequelize/sequelize-crud-mariadb-example-build-crud-node-js-express-restapis-example