Cant insert and pull from database

I’m following along with the meteor tutorial (making a few minor changes here and there) and when it comes to inserting and pulling from the database I don’t seem to be having much luck.

Here is my html file:

  <title>test server</title>

        <h1>test server</h1>
        <div class="loginButton">{{ >loginButtons}}</div>
    {{#if currentUser}}
            <form class="new-job">
                <input type="text" name="job" placeholder="Type to enter new job">
                {{#each jobs}}
                    {{> job}}

<template name="job">

and my javascript file:

Jobs = new Mongo.Collection("jobs");

if (Meteor.isServer){
    Meteor.publish("jobs", function(){
        return Jobs.find()

if (Meteor.isClient){

        jobs: function(){
            return Jobs.find({}, {sort: {createdAt: -1}}); 
        "submit .new-job": function(event){
            var name =;
  "addJob", name);
   = "";

        passwordSignupFields: "USERNAME_ONLY"

    addJob: function(name){
        if (! Meteor.userId()) {
            throw new Meteor.Error("not-authorized");

            name: name,
            createdAt: new Date(),
            owner: Meteor.userId(),
            username: Meteor.user().username

I haven’t made any changes to the database (using the one preinstalled with meteor)

The problem is when I fill in the form and submit, nothing gets stored in the collection. I verify this by taking a look at the db itself and nothing is there.

Furthermore, I manually inserted a document into the collection using the mongo shell ({ name: test, createdAt: new Date()});), and can verify that the document exists in the collection. However, it does not appear on the website within the unordered list.

I have removed the insecure and autopublish packages if that makes a difference

What is wrong with my code that is preventing the client/server from talking to the database?

It appears that whenever I try to add something using the form, I get this error in my browser:

Error invoking Method 'addJob': Method not found [404]

Which is strange to me because it’s explicitly in my the meteor methods section in the js file

I’ve also tried hoisting the meteor methods section to above the client/server logic but that didn’t seem to make a difference

I just threw your code into a quick Meteor Pad ( if you want to see it), and it appears to be working properly. Must be something else on your side.

You define your Methods to live on both server and client, but Meteor.userId() does not exist on the server, so thats probably where your code fails.

    addJob: function(name){
        if (! this.userId) {
            throw new Meteor.Error("not-authorized");

            name: name,
            createdAt: new Date(),
            owner: this.userId,
            username: Meteor.users.findOne(this.userId).username

I just created a new project from scratch and now everything seems to work.

It appears that its due to the directory structure I was using before, where everything was inside a //server directory. after I removed everything to the project root it started working

What is the correct way to structure a meteor project? Surely not everything just gets dumped into the root directory?

Well, the official MDG recommended application structure that will be included in the new Meteor Guide, is in flux - see That being said take a look at the Structuring Your Application section of the docs, then start searching through these forums for application structure recommendations / examples. You’ll find a lot of them, as well as links to several boilerplate starter projects with defined application structures in GitHub (like,,, etc.).