Skip to content

Instantly share code, notes, and snippets.

@kianaditya
Last active June 17, 2020 12:21
Show Gist options
  • Save kianaditya/802615fbfa2313cf6154411d8046735b to your computer and use it in GitHub Desktop.
Save kianaditya/802615fbfa2313cf6154411d8046735b to your computer and use it in GitHub Desktop.
medium express second article
// seeders/index.js
const db = require('../index')
const chance = require('chance').Chance()
const faker = require('faker')
const createSeeds = async () => {
const postsCount = 3
chance.mixin({
post: function () {
return {
title: chance.sentence({ words: 5 }),
content: chance.sentence({ words: 15 }),
}
},
})
for (let index = 0; index < postsCount; index++) {
const post = await db.Posts.create(chance.post())
}
for (let index = 0; index < postsCount; index++) {
const post = await db.Post.create({
title: faker.lorem.sentence(),
content: faker.lorem.sentence(),
})
}
}
module.exports = createSeeds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment