Creating Collections

  1. Add the post collection to your models.js file


     var Posts = new Meteor.Collection("posts");
  2. Create a post using the browser console.


      Posts.insert({title: 'Hello World', body: 'Full body text will go here...', tags: ['first', 'post']});

    By default meteor apps expose all collections to the client. To remove this feature you must remove the autopublish smart package. This will be covered in later lessons.

  3. Query the Post collection to view your newly created post



    This will return the first Post:

      _id: "d65a0282-f1f7-4724-a51d-4414280e2de3"
      body: "Full body text will go here..."
        0: "first"
        1: "post"
      title: "Hello World"`

    Notice how the _id was automatically created for us.


  • Chrome Developer Tools: Console - The Console is accessible from any panel. Unlike the other panels, the Console is not just used for one task, instead it might be used while inspecting the DOM, debugging JavaScript or analyzing HTML parse errors.