Add the post collection to your models.js
file
models.js
var Posts = new Meteor.Collection("posts");
Create a post
using the browser console.
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.
Query the Post
collection to view your newly created post
console
Posts.findOne()
This will return the first Post:
_id: "d65a0282-f1f7-4724-a51d-4414280e2de3"
body: "Full body text will go here..."
tags:
0: "first"
1: "post"
title: "Hello World"`
Notice how the _id
was automatically created for us.