Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Building Single-page Web Apps with Meteor
  • Toc
  • feedback
Building Single-page Web Apps with Meteor

Building Single-page Web Apps with Meteor

By : Fabian Vogelsteller
4.5 (8)
close
Building Single-page Web Apps with Meteor

Building Single-page Web Apps with Meteor

4.5 (8)
By: Fabian Vogelsteller

Overview of this book

If you are a web developer with basic knowledge of JavaScript and want to take on Web 2.0, build real-time applications, or simply want to write a complete application using only JavaScript and HTML/CSS, this is the book for you. This book is based on Meteor 1.0.
Table of Contents (15 chapters)
close
14
Index

Querying a collection

The server did restart when we saved our changes. At this point, Meteor added five post examples to our database.

Note

If the server didn't restart, it means that we made a mistake in the syntax somewhere in our code. When we manually reload our browser or check out the terminal, we will see the error that Meteor gives us and we can fix it.

In case we messed up something in the database, we can always reset it using the $ meteor reset command in the terminal.

We can see these posts by simply opening up the console in our browser and typing the following command:

Posts.find().fetch();

This will return an array with five items, each of them being one of our example posts.

To list these newly inserted posts in our front page, we need to replace the content of our postsList helper in the home.js file with the following lines of code:

Template.home.helpers({
  postsList: function(){
    return Posts.find({}, {sort: {timeCreated: -1}});
  }
});

As we can see, we returned the...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete