Created
February 14, 2018 08:03
-
-
Save shalvah/83c848a49f10bf02e64e7f981c5516c2 to your computer and use it in GitHub Desktop.
Twitter-Realtime-Likes
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
#!/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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment