meteor / tutorials

The Meteor tutorials from meteor.com
https://www.meteor.com/tutorials
MIT License
181 stars 103 forks source link

Angular Tutorial Step 9 Runtime Error #57

Open jannon opened 8 years ago

jannon commented 8 years ago

I'm just going through the Angular tutorial and encountered an error after completing step 9, switching to methods for security. The error is as follows:

Exception while invoking method 'tasks.setChecked' Error: Match error: Expected string, got object

The following code was added in step 9:

'tasks.setChecked' (taskId, setChecked) {
    check(taskId, String);
    check(setChecked, Boolean);

    Tasks.update(taskId, {
      $set: {
        checked: setChecked
      }
    });

Basically, it considers taskId (passed in as task._id) to be an object instead of a String so the check fails. Commenting out the check eliminates the error.

So (1) something might need to be changed in the tutorial and (2) why does it fail on the setChecked method, but not on the remove method?

jflecool2 commented 8 years ago

I also have this problem, doing tutorial step-by-step... (Angularjs todos)

TheRedStripeIrony commented 8 years ago

I have the same issue - Meteor todos Tutorial

massanchik commented 8 years ago

I guess the reason is that you'r created that task from meteor-mongo console. For some reason it creating object instead of string. I have same issue

aaroncalderon commented 8 years ago

I'm having the same issue. I can confirm @massanchik guess. I'm doing the blaze tutorial, but that is irrelevant since the issue is with the MongoDB not the templating engine.

Below is a view from Robomongo 0.8.4 of the tasks collection, notice how documents 1-3 show ObjectId("[id]") as the Key field.

image

jackjack82 commented 8 years ago

I had a similar issue, afterwards I discovered it related to items created before that change. To solve, delete all existing records.

'meteor mongo' 'db.tasks.remove( { } )'

aaroncalderon commented 8 years ago

Resolution

Ok, this seems to be MongoDB's standard behaviour if the _id field is not specified whe inserting the document (record).

Work Around

Delete all records before starting this step.

meteor mongo
db.tasks.remove( { } )

Next Steps

or