How to use insert () to continue the migration?

I want to create only one row using insert()migration in Sequelize. I have seen examples for bulkInsert(), but do not want to use volume. We have this function to create only one line:

insert(instance, tableName, values, options)

But I don’t understand what is the instance here in param? I use bulkInsertbecause it does not request, for example, param. It will be great if you can add an insert to my code written below. Migration library: https://github.com/sequelize/sequelize/blob/master/lib/query-interface.js

//Code for insertion using bulkInsert
module.exports = {
  up: queryInterface => {
    queryInterface.describeTable("Platforms").then(attributes => {
      return queryInterface.bulkInsert("Platforms", [
        {
          id: 6,
          display_name: "Booking.com",
          code: "booking.com"
        }
      ]);
    });
  },
  down: queryInterface => {
    return queryInterface.bulkDelete("Platforms", {
      id: 6
    });
  }
};
+3
source share
1 answer
  import Platform from '../models/Platform';
  module.exports = {
  up: queryInterface => {
    queryInterface.describeTable("Platforms").then(attributes => {
      return queryInterface.insert(Platform, "Platforms", [
        {
          id: 6,
          display_name: "Booking.com",
          code: "booking.com"
        }
      ]);
    });
  },
  down: queryInterface => {
    return queryInterface.bulkDelete("Platforms", {
      id: 6
    });
  }
};

, sequilize.

0

Source: https://habr.com/ru/post/1678728/


All Articles