I’m working through a tutorial using some faker data and I cannot get the avatars to show up. I need to reset or clear my collection each time I restart the server so I can troubleshoot the avatars.
How can I modify my Meteor.startup server side method so I can clear and repopulate my collection every time I restart?
Here is my current main.js server code:
import _ from 'lodash';
import { Meteor } from 'meteor/meteor';
import { Employees } from '../imports/collections/employees';
import { image, helpers } from 'faker';
Meteor.startup(() => {
//Generate fake data - check if any data exists.
const numberRecords = Employees.find({}).count();
console.log(numberRecords);
if(!numberRecords) {
_.times(100, () => {
const {name, email, phone} = helpers.createCard();
const {avatar} = faker.internet.avatar();
Employees.insert({
name, email, phone,
avatar: image.avatar()
});
});
}
//Publish a collection and set a limit
Meteor.publish('employees', function(per_page) {
return Employees.find({}, { limit: per_page });
});
});