Socket
Socket
Sign inDemoInstall

sequelize-models-collector

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sequelize-models-collector

This package gather Sequelize models into object and allow to set association within file of model declaration


Version published
Weekly downloads
1
Maintainers
1
Install size
3.48 kB
Created
Weekly downloads
 

Readme

Source

sequelize-models-collector

FEATURES

  • Allow to set association within file of model declaration
  • Allow to import any models directly from models directory

Installing

$ npm i --save sequelize-models-collector

Usage

Assume import in index.js in models directory

module.exports = require('seuelize-models-collector')(Sequelize, sequelize, dirname[, cofig]);

arguments:

1. Sequelize function
2. Sequlize instance
3. Path to models directory
4. config (optional, by default {})

Model and relations declaration example

module.exports = function(Sequelize, sequelize) {
    const User = sequelize.define('User', {
        id: {
            type: Sequelize.INTEGER.UNSIGNED,
            autoIncrement: true,
            allowNull: false,
            primaryKey: true
        },
        name: Sequelize.STRING,
        email: Sequelize.STRING
    },
        {
        tableName: 'user'
        });
    User.relate = function (models) {
        models.User.hasMany(models.Order);
        models.User.hasMany(models.Product);
        models.User.hasOne(models.Cart);
    };

    return User;
};

Keywords

FAQs

Last updated on 07 Feb 2019

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc