Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sequelize-models-collector

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 07 Feb 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc