2017-09-24 63 views
1

我試圖用種子一sequilize UUID generateUUID 但我得到這個錯誤Seed file failed with error: sequelize.Utils.generateUUID is not a function TypeError: sequelize.Utils.generateUUID is not a function如何種子uuidv4與sequ​​elize

我如何播種UUID?

return queryInterface.bulkInsert('companies', [{ 
     id: sequelize.Utils.generateUUID(), 
     name: 'Testing', 
     updated_at: new Date(), 
     created_at: new Date() 
    }]); 

回答

0

只需安裝UUID:

npm install uuid 

,並在你的種子文件:

const uuidv4 = require('uuid/v4'); 

module.exports = { 
    up: (queryInterface, Sequelize) => { 
    return queryInterface.bulkInsert('yourTableName', [ 
     { 
     id: uuidv4() 
     }], 
{}); 
相關問題