sequelize-interval-postgres

    1.0.0 • Public • Published

    sequelize-interval-postgres

    NPM version

    Add support for INTERVAL data-type for PostgreSQL in Sequelize.

    Motivation

    Read:

    Install

    npm install --save sequelize-interval-postgres

    Use to define models

    models/my_model.js

    const withInterval = require('sequelize-interval-postgres');
     
    module.exports = function (sequelize, SequelizeDataTypes) {
      const DataTypes = withInterval(SequelizeDataTypes);
     
      const MyModel = sequelize.define('myModel', {
        someIntervalField: {
          type: DataTypes.INTERVAL
        },
     
        // ...
      });
     
      // ...
     
      return MyModel;
    };

    Use in migrations

    migrations/<timestamp>-add-some-interval-field-to-my-model.js

    const withInterval = require('sequelize-interval-postgres');
     
    module.exports = {
      up: function (queryInterface, SequelizeBase) {
        const Sequelize = withInterval(SequelizeBase);
     
        return queryInterface.addColumn('myModel', 'someIntervalField', {
          type: Sequelize.INTERVAL
        });
      },
     
      // ...
    };

    Install

    npm i sequelize-interval-postgres

    DownloadsWeekly Downloads

    606

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    5.79 kB

    Total Files

    7

    Last publish

    Collaborators

    • aosorio