2016-11-26 11:17:01 +09:00
|
|
|
/*
|
|
|
|
|
|
|
|
Seed the database with some dummy content.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2016-11-18 16:01:27 +09:00
|
|
|
import Movies from './collection.js';
|
|
|
|
import Users from 'meteor/nova:users';
|
2016-12-13 11:32:23 +09:00
|
|
|
import { newMutation } from 'meteor/nova:core';
|
2016-11-18 16:01:27 +09:00
|
|
|
|
|
|
|
const seedData = [
|
|
|
|
{
|
|
|
|
name: 'Star Wars',
|
|
|
|
year: '1973',
|
|
|
|
review: `A classic.`,
|
|
|
|
privateComments: `Actually, I don't really like Star Wars…`
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Die Hard',
|
|
|
|
year: '1987',
|
|
|
|
review: `A must-see if you like action movies.`,
|
|
|
|
privateComments: `I love Bruce Willis so much!`
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Terminator',
|
|
|
|
year: '1983',
|
|
|
|
review: `Once again, Schwarzenegger shows why he's the boss.`,
|
|
|
|
privateComments: `Terminator is my favorite movie ever. `
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Jaws',
|
|
|
|
year: '1971',
|
|
|
|
review: 'The original blockbuster.',
|
|
|
|
privateComments: `I'm scared of sharks…`
|
|
|
|
},
|
2016-11-19 18:01:05 +09:00
|
|
|
{
|
|
|
|
name: 'Die Hard II',
|
|
|
|
year: '1991',
|
|
|
|
review: `Another classic.`
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Rush Hour',
|
|
|
|
year: '1993',
|
|
|
|
review: `Jackie Chan at his best.`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Citizen Kane',
|
|
|
|
year: '1943',
|
|
|
|
review: `A disappointing lack of action sequences.`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Commando',
|
|
|
|
year: '1983',
|
|
|
|
review: 'A good contender for highest kill count ever.',
|
|
|
|
},
|
|
|
|
];
|
2016-11-18 16:01:27 +09:00
|
|
|
|
|
|
|
Meteor.startup(function () {
|
2016-11-24 15:47:51 +09:00
|
|
|
if (Users.find().fetch().length === 0) {
|
|
|
|
Accounts.createUser({
|
|
|
|
username: 'DemoUser',
|
|
|
|
email: 'dummyuser@telescopeapp.org',
|
|
|
|
profile: {
|
|
|
|
isDummy: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2016-11-18 16:01:27 +09:00
|
|
|
const currentUser = Users.findOne();
|
|
|
|
if (Movies.find().fetch().length === 0) {
|
|
|
|
seedData.forEach(document => {
|
|
|
|
newMutation({
|
|
|
|
action: 'movies.new',
|
|
|
|
collection: Movies,
|
|
|
|
document: document,
|
|
|
|
currentUser: currentUser,
|
|
|
|
validate: false
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|