2016-03-31 12 views

cevap

1

Önce development:{seederStorage:'sequelize'} arasında config.js yılında seederStorage:'sequelize' ekleyin kök dizininde ekme klasör oluşturmak o json nesneleri offers ve tablo alanları olan db burada tablo adı offer ama vereceğiniz sequelize seed:create --name nameofseed kullanarak tohum dosyası oluşturun. ekim makinesi oluşturduktan sonra sırasıyla migrate ve run gerekir. burada: sequelize db:seed:all tohumunu çalıştırma komutu, geçiş işlemini çalıştırmadan önce: sequelize db:migrate. {SeederStorage: 'sequelize'}

module.exports = { 
     up: function(queryInterface, Sequelize) { 
     queryInterface.bulkInsert('offers', [{ 
      ban: [1], 
      sDate: '2016-03-31T08:00:10.354Z', 
      eDate: '2016-03-31T08:00:10.354Z', 
      isActive: true, 
      reminder: false, 
      sold: false, 
      couponFor: 'Coupon Code', 
      couponVal: 'Flat20%', 
      createdAt: '2016-03-31T08:00:10.354Z', 
      updatedAt: '2016-03-31T08:00:10.354Z' 
     }, 
     { 
      ban: [1, 2], 
      sDate: '2016-03-31T08:00:10.354Z', 
      eDate: '2016-03-31T08:00:10.354Z', 
      isActive: true, 
      reminder: false, 
      sold: false, 
      couponFor: 'Coupon Code', 
      couponVal: 'Flat40%', 
      createdAt: '2016-03-31T08:00:10.354Z', 
      updatedAt: '2016-03-31T08:00:10.354Z' 
     }, 
     { 
      ban: [1, 2], 
      sDate: '2016-03-31T08:00:10.354Z', 
      eDate: '2016-03-31T08:00:10.354Z', 
      isActive: true, 
      reminder: false, 
      sold: false, 
      couponFor: 'Coupon Code', 
      couponVal: 'Flat60%', 
      createdAt: '2016-03-31T08:00:10.354Z', 
      updatedAt: '2016-03-31T08:00:10.354Z' 
     }, 
     { 
      ban: [1], 
      sDate: '2016-03-31T08:00:10.354Z', 
      eDate: '2016-03-31T08:00:10.354Z', 
      isActive: true, 
      reminder: false, 
      sold: false, 
      couponFor: 'Coupon Code', 
      couponVal: 'Flat100%', 
      createdAt: '2016-03-31T08:00:10.354Z', 
      updatedAt: '2016-03-31T08:00:10.354Z' 
     }], {}); 
     /* 
      Add altering commands here. 
      Return a promise to correctly handle asynchronicity. 

      Example: 
      return queryInterface.bulkInsert('Person', [{ 
      name: 'John Doe', 
      isBetaMember: false 
      }], {}); 
     */ 
     }, 

     down: function(queryInterface, Sequelize) { 
     /* 
      Add reverting commands here. 
      Return a promise to correctly handle asynchronicity. 

      Example: 
      return queryInterface.bulkDelete('Person', null, {}); 
     */ 
     } 
    }; 
+0

eksik sequelize cli ama bana bayrak tohum listeleme çalıştı' config.js içinde ayarlı değil ya onun ince – Shrikant

+0

Bir göçte bulkInsert() kullanabilir dosya? – maxwell

+0

Lütfen sıralı bir örnek veya belge linki ekleyebilir misiniz? Şimdiden teşekkürler. –