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

@ckpack/sequelize-autoload-models

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

@ckpack/sequelize-autoload-models

sequelize autoload models

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

sequelize-autoload

sequelize-autoload-models

example

models

./models
├── data.js
├── table
│   ├── table1.js
│   └── table2.js
└── user.js

/models/user.js

function user (sequelize) {
  sequelize.define('modelName', {
    columnA: {
        type: Sequelize.BOOLEAN,
        field: 'column_a'
    },
    columnB: Sequelize.STRING,
    columnC: 'MY VERY OWN COLUMN TYPE'
  });
}

modules.exports = user;
const path = require('path');
const { Sequelize } = require('sequelize');
const autoloadModels = require('@c_kai/sequelize-autoload');


let sequelize = new Sequelize('postgres://postgres:postgres@localhost:5432/dbname');
sequelize = autoloadModels( sequelize, path.join(__dirname, './models'));

console.log(sequelize.models);
//{ data: data, table1: table1, table2: table2, user: user }

//now you can make the standard CRUD queries
console.log(sequelize.models.user.create;
// detail: https://sequelize.org/master/manual/model-querying-basics.html

Keywords

FAQs

Package last updated on 25 Feb 2021

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