Setting up a Mongo database for a meteor project has been tricky for me. I've created a startup.js file to load the necessary files, but as soon as I start meteor, it crashes. Can anyone lend a hand, please?
Here is a snippet from the HTML file:
<body>
<div class="container">
{{> images}}
</div>
</body>
<template name="images">
<div class="row">
{{#each images}}
<div class="col-xs-12 col-md-3">
<div class="thumbnail">
<img class="js-image" src="{{img_src}}" alt="{{img_alt}}" />
</div>
</div>
{{/each}}
</div>
</template>
And this is the content of the startup.js file:
if (Meteor.if(Meteor.isServer) {
Meteor.startup(function() {
if (Images.find().count() == 0) {
Images.insert({
img_src: "laptops.jpg",
img_alt: "some laptops on a table"
}
})
}
});
})
Furthermore, here is the image_share.js file:
Images = new Mongo.Collection("images");
if (Meteor.isClient) {
var img_data = [{
img_src: "laptops.jpg",
img_alt: "some laptops on a table"
}, {
img_src: "bass.jpg",
img_alt: "a bass player"
}, ];
Template.images.helpers({
images: img_data
});
Template.images.events({
'click .js-image': function(event) {
$(event.target).css("width", "50px");
}
});
}
Here is the error log that I'm encountering:
W20160802-22:15:47.535(3)? (STDERR) (function(Npm,Assets){(function(){if (Meteor.if(Meteor.isServer){
W20160802-22:15:47.535(3)? (STDERR) ^
W20160802-22:15:47.535(3)? (STDERR) SyntaxError: Unexpected token {
W20160802-22:15:47.535(3)? (STDERR) at /data/coursera/meteor.js/week_1/fotini_test/.meteor/local/build/programs/server/boot.js:278:30
W20160802-22:15:47.535(3)? (STDERR) at Array.forEach (native)
W20160802-22:15:47.535(3)? (STDERR) at Function._.each._.forEach (/home/fotini/.meteor/packages/meteor-tool/.1.3.2_4.s16sw2++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20160802-22:15:47.535(3)? (STDERR) at /data/coursera/meteor.js/week_1/fotini_test/.meteor/local/build/programs/server/boot.js:133:5
=> Exited with code: 8
`