Last active
June 17, 2020 12:21
-
-
Save kianaditya/802615fbfa2313cf6154411d8046735b to your computer and use it in GitHub Desktop.
medium express second article
This file contains hidden or 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
// 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