Created
July 29, 2020 13:59
-
-
Save derduskenga/174a58365d4191fba54b7fbaf078ca86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const fake = require('faker'); | |
module.exports = { | |
up: async (queryInterface, Sequelize) => { | |
let users = await queryInterface.sequelize.query( | |
`SELECT id from Users;` | |
); | |
let posts = []; | |
for(let i=0; i<=100; i++){ | |
posts.push({ | |
post_title:fake.lorem.sentence(), | |
post_text:fake.lorem.paragraph(), | |
status:fake.random.boolean(), | |
userId:fake.random.arrayElement(users[0]).id, | |
createdAt: new Date(), | |
updatedAt:new Date() | |
}); | |
} | |
await queryInterface.bulkInsert('Posts',posts, {}); | |
}, | |
down: async (queryInterface, Sequelize) => { | |
await queryInterface.bulkDelete('Posts', null, {}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment