Meteor Js Interview Questions And Answers

meteor js interview questions and answers   Top 11 Meteor Js Interview Questions And Answers

1) What is Meteor JS?

Meteor is a full-stack JavaScript platform for building web and mobile apps. Meteor makes it easier to create real-time apps, since it alone offers a full ecosystem to work with, instead of combining couple of different tools and frameworks.

Meteor includes a key set of technologies for building connected-client reactive applications, a build tool, and a curated set of packages from the Node.js and general JavaScript community.


2) What are the different features of Meteor JS?

Following are the features of Meteor JS:

● Web and Mobile ? Meteor offers a platform for developing Web, Android and IOS apps.
● Universal Apps ? The same code for web browsers and mobile devices.
● Meteor Galaxy ? Cloud service for Meteor app deployment.
● Packages ? Huge number of packages that are easy to install and use.


3) What are the advantages of Meteor JS?

Following are the advantages of Meteor JS:

● It is very simple and easy to use.
● Meteor apps are real time by default.
● Official and community packages are huge time saver.
● Developers only need JavaScript for server and client side development.


4) What are the limitations of Meteor JS?

Following are the limitations:

● Its not suitable for large and complex applications.
● It is sort of limiting for the developers in some or the other way.


5) What is block template in Meteor JS?

Here is the example of block template:



meteorApp.html

<head>
   <title>meteorApp</title>
</head>
 
<body>
   <div>
      {{#each paragraphs}}
         {{> paragraph}}
      {{/each}}
   </div>
</body>
 
<template name = ""paragraph"">
   <p>{{text}}</p>
</template>

meteorApp.js

if (Meteor.isClient) {
   
   // This code only runs on the client
   Template.body.helpers({
      paragraphs: [
         { text: ""This is paragraph 1..."" },
         { text: ""This is paragraph 2..."" },
         { text: ""This is paragraph 3..."" },
         { text: ""This is paragraph 4..."" },
         { text: ""This is paragraph 5..."" }
      ]
   });
}



6) How to create new collection in Meteor JS?

New collection can be created in Meteor JS by below code:

MyCollection = new Mongo.Collection('myCollection');


7) How to add data in Meteor JS?

Once the collection is created, we can add data by using the insert method:

MyCollection = new Mongo.Collection('myCollection');

var myData = {
   key1: ""value 1..."",
   key2: ""value 2..."",
   key3: ""value 3..."",
   key4: ""value 4..."",
   key5: ""value 5...""
}

MyCollection.insert(myData);


8) How to find the data in Meteor JS?

The find method can be used to search for data in the collection:

MyCollection = new Mongo.Collection('myCollection');

var myData = {
   key1: ""value 1..."",
   key2: ""value 2..."",
   key3: ""value 3..."",
   key4: ""value 4..."",
   key5: ""value 5...""
}

MyCollection.insert(myData);

var findCollection = MyCollection.find().fetch();
console.log(findCollection);


9) How to update the data in Meteor JS?

The data can be updated using update method:

MyCollection = new Mongo.Collection('myCollection');

var myData = {
   key1: ""value 1..."",
   key2: ""value 2..."",
   key3: ""value 3..."",
}

MyCollection.insert(myData);

var findCollection = MyCollection.find().fetch();
var myId = findCollection[0]._id;

var updatedData = {
   key1: ""updated value 1..."",
   key2: ""updated value 2..."",
   key3: ""updated value 3..."",
}

MyCollection.update(myId, updatedData);

var findUpdatedCollection = MyCollection.find().fetch();
console.log(findUpdatedCollection);


10) How to delete the data in Meteor JS?

The data can be deleted using remove method:

MyCollection = new Mongo.Collection('myCollection');

var myData = {
   key1: ""value 1..."",
   key2: ""value 2..."",
   key3: ""value 3..."",
   key4: ""value 4..."",
   key5: ""value 5...""
}

MyCollection.insert(myData);

var findCollection = MyCollection.find().fetch();
var myId = findCollection[0]._id;

MyCollection.remove(myId);

var findDeletedCollection = MyCollection.find().fetch();
console.log(findDeletedCollection);


11) What are Meteor sessions?

These are used to save the data while the users are using the app. This data will be deleted when the user leaves the app.
Session.set() method is used to set the data locally in session whereas Session.get() is used to retrieve the data.

if (Meteor.isClient) {
  
   var myData = {
      key1: ""value1"",
      key2: ""value2""
   }

   Session.set('mySession', myData);

   var sessionDataToLog = Session.get('mySession');
   console.log(sessionDataToLog);
}