Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env node
- let faker = require('faker');
- let Post = require('../models/post');
- // connect to MongoDB
- require('mongoose').connect('mongodb://localhost/poster');
- // remove all data from the collection first
- Post.remove({})
- .then(() => {
- let posts = [];
- for (let i = 0; i < 30; i++) {
- posts.push({
- text: faker.lorem.sentence(),
- posted_at: faker.date.past(),
- likes_count: Math.round(Math.random() * 20),
- author: faker.name.findName()
- });
- }
- return Post.create(posts);
- }).then(() => {
- process.exit();
- }).catch((e) => {
- console.log(e);
- process.exit(1);
- });
Add Comment
Please, Sign In to add comment