The meteorite experienced a crash as startup.js attempted to connect with Mongo

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

`

Answer №1

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"
            });
        }
    });
}

There is a missing closing bracket ")" and a few other mistakes were made.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Internet Explorer versions 9 and 10 do not support the CSS property "pointer-events: none"

In Firefox, the CSS property pointer-events: none; functions properly. However, it does not work in Internet Explorer 9-10. Are there any alternative approaches to replicate the functionality of this property in IE? Any suggestions? ...

What is the functionality of the disabled attribute on an option tag within a dropdown select menu?

I am working with a code snippet that involves understanding how the attribute:disabled functions on an <option> within a <select> element! Let's say I have a dropdown for ratings and I select the 5-star option (★★★★★). Upon sel ...

When using the post method in jQuery, it may send data that is unspecified in the request body

Greetings to everyone and I hope you have a fantastic start to the new year. I've been attempting to operate an API on localhost that will store input data in MongoDB. The issue arises when attempting to send data using the post method. The request ...

The troubleshooting issue with jQuery animate Scrolltop malfunctioning

My goal is to use jQuery to scroll the page to a specific div when a button is clicked. Despite not seeing any errors in the JavaScript console, the page does not actually scroll to the desired location. I have tried placing the jQuery js file before and a ...

Node.js is patiently waiting for the query to be executed

I am currently working on a project using Node.js in conjunction with MongoDB (specifically mongoose and express). As a precaution, I feel the need to validate user data directly against the database due to trust issues. Here is an example of the input d ...

Vue app hosted on Firebase displays a blank page when user logs in

After deploying my Vue2 project to Firebase hosting server, visitors are required to log in to access the other pages. The issue is that once a user successfully logs in, they are redirected to the next page but it appears blank. Below is what the firebas ...

Is there a way to assign a dynamic value to an input just once, and then retain the updated value without it changing again

During a for loop, I have an input element (type number) that needs its value modified by decrease and increase buttons: <div class="s-featured-list__item s-featured-list__item--expandable" v-for="(item, itemIndex) in category.items" ...

How can I prevent div duplication when working with ui-router?

I created a basic demonstration to get familiar with ui router. Unfortunately, I encountered an issue of duplicated views when utilizing ui router. Below is the snippet of the stateProvider section: app.config(function($stateProvider,$urlRouterProvider) ...

How to Pass and Execute Asynchronous Callbacks as Props in React Components

I'm curious about the correct syntax for passing and executing async calls within React components. Specifically: Many times, I'll have a function that looks like this: const doAsync = async (obj) => { await doSomethingAsync(obj) } ...and ...

Guide to ordering objects within an array by their createdAt property in mongoose

I'm attempting to organize the products array based on the createdAt date. Here is my orders model: const itemSchema = new Schema( { productId: { type: Schema.Types.ObjectId, ref: 'Product' }, quantity: { typ ...

The styling of MUI components adapts when the Navigate component in React Router is initialized

Incorporating React Router into my application has led to an unexpected side-effect while implementing the <Navigate to="/"> component (which goes to <AthleteHomepage />) upon state change. Currently, I haven't set up dynamic sta ...

Update the second dropdown menu depending on the selection made in the first dropdown menu

While I know this question has been posed previously, I'm struggling to apply it to my current situation. In my MySQL database, I have a table named "subject" that includes columns for subject name and subject level. Here's an example: Subject ...

What is the best way to retrieve data from MySQL for the current month using JavaScript?

I need to retrieve only the records from the current month within a table. Here is the code snippet: let startDate = req.body.startDate let endDate = req.body.endDate let result = await caseRegistration.findByDate({ p ...

Instructions on how to showcase a standard text within a designated text container

I am currently facing an issue with a textarea or textbox that is dynamically receiving URLs from a database. The textbox is displaying the full URL address, which is not visually appealing. I would like to replace this with some generic text such as "cl ...

Adjust the primary scrolling section of a webpage to halt once it reaches a specific distance from the bottom of the viewport

I am facing a situation where I need to ensure that when scrolling down, a fixed pink menu bar at the bottom of the page does not overlap with the main blue content. This can be achieved by treating the blue content as an iframe positioned 60px from the bo ...

Traverse through the JSON data until a certain condition is satisfied, then proceed to tally the number

Looking to parse a json file containing user data and points. The goal is to loop through the data until the _id matches the userId, then determine the position of that user in the list based on the number of objects. The json file provided below already ...

order documents in a subdocument by date with mongoose and node.js

Having difficulty sorting posts by the date of updated_at instead of creation? The code snippet provided currently displays posts in order of creation, but you need them to be sorted by the updated date. See the schema and route code below for reference: ...

Navigating the parent navController in Ionic 2: A step-by-step guide

I'm currently honing my skills in Ionic 2 by creating a basic app, but I've encountered an issue that has me stumped. The app features an ion-nav element for the login page, then transitions to a tabs navigator after successful login. The struct ...

Layer one image on top of another using z-index

I'm having trouble layering one image on top of another in my code. Here is my code: body { background: #000000 50% 50%; height: 100% width:100%; overflow-x: hidden; overflow-y: hidden; } .neer { z-index: 100; position: absolute; } ...

Utilizing Sequelize with Typescript for referential integrity constraints

After defining these two Sequelize models: export class Users extends Model<Users> { @HasMany(() => UserRoles) @Column({ primaryKey: true, allowNull: false, unique: true }) UserId: string; @Column({ allowNull: false, unique: tru ...