Premium lesson

Retrieving Records From Tables in Sequelize

Sequelize·6 min read·Jan 1, 2025

For this lesson, let's consider this MySQL table named employees, similar to the one used in the lesson called "Retrieving Records From a Table With Queries in MySQL":

CREATE TABLE employees (  id INT AUTO_INCREMENT PRIMARY KEY,  first_name VARCHAR(255) NOT NULL,  last_name VARCHAR(255) NOT NULL,  department ENUM('Sales', 'Engineering', 'HR', 'Marketing') NOT NULL,  hire_date DATE NOT NULL,  salary INT NOT NULL);

That contains these SQL records:

mysql> SELECT * FROM employees;+----+------------+-----------+-------------+------------+--------+| id | first_name | last_name | department  | hire_date  | salary |+----+------------+-----------+-------------+------------+--------+|  1 | John       | Doe       | Sales       | 2022-01-15 | 50000  ||  2 | Jane       | Smith     | Engineering | 2020-03-22 | 70000  ||  3 | Alice      | Johnson   | HR          | 2019-07-30 | 45000  ||  4 | Bob        | Brown     | Sales       | 2018-11-10 | 52000  |
icon light bulb key

Unlock the Build RESTful APIs in Node.js module

Learn how to build real database-backed and framework-powered RESTful APIs with MySQL, Sequelize, and Express.

You get immediate access to:

  • 37 focused lessons across MySQL, Sequelize, backend, and Express
  • 4 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module