Supercharging Node.js Applications with Sequelize: Create high-quality Node.js apps effortlessly while interacting with your SQL database
- Length: 266 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-10-28
- ISBN-10: 1801811555
- ISBN-13: 9781801811552
- Sales Rank: #203404 (See Top 100 Books)
A hands-on implementation guide to application development in Node.js using the powerful Sequelize ORM
Key Features
- Use the highly powerful JavaScript library to map your database to objects easily
- Build an application from scratch with easy-to-follow steps and examples
- Discover industry best practices, tips, and techniques on Sequelize to manage your database with ease
Book Description
Continuous changes in business requirements can make it difficult for programmers to organize business logic into database models, which turns out to be an expensive operation as changes to the database may result in errors and incongruity within applications. Supercharging Node.js Applications with Sequelize helps you get to grips with Sequelize, a reliable ORM that enables you to alleviate these issues in your database and applications.
With Sequelize, you’ll no longer need to store information in flat files or memory. This book takes a hands-on approach to implementation and associated methodologies for your database that will have you up and running in no time. You’ll learn how to configure Sequelize for your Node.js application properly, develop a better sense of understanding of how this ORM works, and find out how to manage your database from Node.js using Sequelize. Finally, you’ll be able to use Sequelize as the database driver for building your application from scratch.
By the end of this Node.js book, you’ll be able to configure, build, store, retrieve, validate, and associate your data from a database to a Node.js application.
What you will learn
- Configure and optimize Sequelize for your application
- Validate your database and hydrate it with data
- Add life cycle events (or hooks) to your application for business logic
- Organize and ensure the integrity of your data even on preexisting databases
- Scaffold a database using built-in Sequelize features and tools
- Discover industry-based best practices, tips, and techniques to simplify your application development
Who this book is for
This book is for beginner- to intermediate-level Node.js developers looking to upgrade their skills and use Sequelize as their ORM of choice. Basic knowledge of and prior experience with JavaScript and SQL are needed to make the most out of this book.
Supercharging Node.js Applications with Sequelize Foreword Contributors About the author About the reviewers Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Part 1 – Installation, Configuration, and the Basics Chapter 1: Introduction to Sequelize and ORM in Node.js Technical requirements Introducing Sequelize Advantages of using Sequelize over other alternatives Installing the necessary applications, frameworks, and tools to help get you started Installing MySQL Creating a database Installing Node.js Configuring Sequelize within an Express application Connecting Sequelize with Express Summary Chapter 2: Defining and Using Sequelize Models Technical requirements Defining models for a database Exploring the various Sequelize data types and when to use them STRING CHAR TEXT/TINYTEXT/MEDIUMTEXT/LONGTEXT CITEXT NUMBER INTEGER/TINYINT/SMALLINT/MEDIUMINT/BIGINT FLOAT/REAL DECIMAL/DOUBLE BOOLEAN DATE/DATEONLY/TIME NOW HSTORE JSON JSONB BLOB UUID/UUIDV1/UUIDV4 VIRTUAL ENUM ARRAY GEOMETRY GEOGRAPHY CIDR/INET/MACADDR TSVECTOR Migrating schematic changes and data from Sequelize to the database Migrating schematic changes Initializing seed data Manipulating and querying data using Sequelize Reading data Complex querying Deleting data Updating and saving data Creating data Ordering and grouping Limits and pagination Advanced Sequelize options for defining models sequelize modelName defaultScope/scopes omitNull timestamps paranoid createdAt/updatedAt/deletedAt underscored freezeTableName tableName name schema engine charset collation comment initialAutoIncrement hooks validate indexes Summary Part 2 – Validating, Customizing, and Associating Your Data Chapter 3: Validating Models Technical requirements Using validations as constraints allowNull unique Built-in validations Applying validations to our project Creating custom validation methods Creating custom attribute validators Executing validations while performing asynchronous operations Handling validation errors Summary Chapter 4: Associating Models Technical requirements Association methods hasOne belongsTo hasMany belongsToMany Renaming associations Relationship patterns One-to-One One-to-Many Many-to-Many Using custom foreign key definitions Querying associations with eager loading and lazy loading Lazy loading Eager loading Using advanced association options Using scopes with associations Creating Super Many-to-Many relationships Using polymorphic associations Applying associations to Avalon Airlines Summary Chapter 5: Adding Hooks and Lifecycle Events to Your Models Technical requirements Order of operations for lifecycle events Defining, removing, and executing lifecycle events Defining instance and model lifecycle events Removing lifecycle events Executing lifecycle events Using lifecycle events with associations and transactions Putting it all together Summary References Chapter 6: Implementing Transactions with Sequelize Technical requirements Managed and unmanaged transactions Running transactions concurrently Running transactions concurrently with Sequelize Running transactions with CLS Isolation levels and advanced configuration Locking rows with Sequelize Using life cycle events for transactions Putting it all together Summary Chapter 7: Handling Customized, JSON, and Blob Data Types Technical requirements Querying JSON and JSONB data Using the BLOB column type Creating custom data types Putting it all together Summary Part 3 – Advanced Queries, Using Adapters, and Logging Queries Chapter 8: Logging and Monitoring Your Application Technical requirements Configuring logging with all of the available interfaces Integrating third-party logging applications such as Pino or Bunyan Integrating with Pino Integrating with Bunyan Collecting metrics and statistics for Sequelize with OpenTelemetry Summary Chapter 9: Using and Creating Adapters Technical requirements Installing, configuring, and integrating AdminJS with Sequelize Integrating Sequelize with GraphQL Creating our own adapter Summary Chapter 10: Deploying a Sequelize Application Technical requirements Refactoring and adding flight schedule routes Integrating Express’ static middleware and securing the admin interface Creating a page to list and book flights Deploying the application Summary Index Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Supercharging Node.js Applications with Sequelize: Create high-quality Node.js apps effortlessly while interacting with your SQL database
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.