Skip to content

Instantly share code, notes, and snippets.

View ajLapid718's full-sized avatar

Allan James Lapid ajLapid718

View GitHub Profile
@ajLapid718
ajLapid718 / sequelizeMoreAssociations.md
Created November 20, 2018 07:19
An overview of querying and associations involving Sequelize's belongsToMany() method in particular

Sequelize: BelongsToMany()

Official Description From The Documentation

Belongs-To-Many associations are used to connect sources with multiple targets.

Furthermore the targets can also have connections to multiple sources.

Project.belongsToMany(User, { through: 'UserProject' });

User.belongsToMany(Project, { through: 'UserProject' });

@ajLapid718
ajLapid718 / sequelizeAssociations.md
Last active November 20, 2022 08:20
An overview of querying and associations via Sequelize

Sequelize: Associations

Official Description From The Documentation

This section describes the various association types in Sequelize. When calling a method such as User.hasOne(Project), we say that the User model (the model that the function is being invoked on) is the source and the Project model (the model being passed as an argument) is the target.

Background Information From Wikipedia

Database design is the organization of data according to a database model. The designer determines what data must be stored and how the data elements interrelate. With this information, they can begin to fit the data to the database model. Database design involves classifying data and identifying interrelationships.

Overview

With PostgreSQL as our object-relational database management system (ORDBMS) and Sequelize as our library of choice to implement object-relational mapping (ORM), we will be covering the bases when it comes to the associations, or relationships, that exist among the various table