3.0.1 • Published 5 years ago

pomegranate-sequelize-pg v3.0.1

Weekly downloads
18
License
MIT
Repository
github
Last release
5 years ago

Pomegranate-sequelize-pg

Adds models to the SQL injectable object provided by pomegranate-sequelize-core

Install

npm install --save pomegranate-sequelize-pg

Usage

Run pomegranate build to generate a config file for connection details. Place you model files in the configured work directory (defaults to ./models).

Your loaded models will be available on the SQL injectable SQL.<modelName>

Model File

This format is expected by the plugin for your model files. The classMethods.associate method will be called by the plugin when all of the models are loaded.

// file ./models/User.js
// Available as SQL.User

module.exports = function(sequelize, DataTypes) {
  var User = sequelize.define('user', {
      name: {type: DataTypes.STRING},
      email: {type: DataTypes.STRING},
  }, 
  {
    classMethods: {
      associate: function(models) {
        //define associations if any.
        User.belongsTo(models.Location)
      }
  }
  });

  // must return your model.
  return Feed
};
2.2.0

5 years ago

2.1.0

5 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.3

6 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.0.0

8 years ago

0.2.0

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago