Socket
Socket
Sign inDemoInstall

sequelize

Package Overview
Dependencies
17
Maintainers
7
Versions
622
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sequelize

Multi dialect ORM for Node.JS


Version published
Maintainers
7
Install size
9.74 MB
Created

Package description

What is sequelize?

Sequelize is a promise-based Node.js ORM (Object-Relational Mapping) library for Postgres, MySQL, MariaDB, SQLite, and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication and more. Sequelize follows the Active Record paradigm and allows developers to define models and their relationships in a way that abstracts database access, making it easier to maintain and evolve the application codebase.

What are sequelize's main functionalities?

Model Definition

This feature allows you to define models in Sequelize, which represent tables in the database. Each model can have various attributes and their respective data types.

const User = sequelize.define('user', { username: Sequelize.STRING, birthday: Sequelize.DATE });

CRUD Operations

Sequelize provides methods for creating, reading, updating, and deleting records in the database, which correspond to the CRUD operations.

User.create({ username: 'alice', birthday: new Date(1986, 6, 20) }); User.findAll(); User.update({ username: 'alicejr' }, { where: { id: 1 } }); User.destroy({ where: { id: 1 } });

Associations

This feature allows you to define associations between models. For example, a user can have many posts, and a post belongs to a user.

User.hasMany(Post); Post.belongsTo(User);

Transactions

Sequelize supports transactions which allow you to execute multiple queries in an atomic way, ensuring data integrity.

sequelize.transaction(transaction => { return User.create({ username: 'bob' }, { transaction }); });

Migrations

Sequelize has a migration tool that allows you to define changes to the database schema, which can be applied and rolled back programmatically.

module.exports = { up: (queryInterface, Sequelize) => { return queryInterface.createTable('users', { id: { allowNull: false, autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER }, username: { type: Sequelize.STRING } }); }, down: (queryInterface, Sequelize) => { return queryInterface.dropTable('users'); } };

Other packages similar to sequelize

Readme

Source

Sequelize

npm version Build Status Windows Build status codecov Bountysource Slack Status npm downloads node License semantic-release Greenkeeper badge

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

Table of Contents

Installation

$ npm install --save sequelize

# And one of the following:
$ npm install --save pg pg-hstore
$ npm install --save mysql2
$ npm install --save sqlite3
$ npm install --save tedious // MSSQL

Sequelize follows SEMVER. Supports Node v4 and above to use ES6 features.

Features

  • Schema definition
  • Schema synchronization/dropping
  • 1:1, 1:M & N:M Associations
  • Through models
  • Promises
  • Hooks/callbacks/lifecycle events
  • Prefetching/association including
  • Transactions
  • Migrations
  • CLI (sequelize-cli)

Documentation

Responsible disclosure

If you have any security issue to report, contact project maintainers privately. You can find contact information here

Resources

Keywords

FAQs

Last updated on 19 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc