Paul
Paul

Reputation: 1066

Hooks in FeathersJS or Sequelize

Given the scenario I want to insert a default value in a database column (date_introduced). I'm considering two alternatives:

What would be the specific benefits for each alternative? But of course there are other scenario's like checking on an input, etc... each with their own concerns.

Upvotes: 0

Views: 124

Answers (1)

Aditya Jamuar
Aditya Jamuar

Reputation: 127

Write a simple migration for your Sequelize DB.

'use strict';

module.exports = {
  up: function (queryInterface, Sequelize) {
    return queryInterface.changeColumn('tableName', 'columnName', {
      type: Sequelize.STRING,
      defaultValue: <defaultValue>
    });
  },

  down: function (queryInterface, Sequelize) {
    return queryInterface.changeColumn('tableName', 'columnName', {
      type: Sequelize.STRING,
      defaultValue: null
    });
  }
};

You can find more info in official documentation of feathers.

Upvotes: 1

Related Questions