meteor-document-methods icon indicating copy to clipboard operation
meteor-document-methods copied to clipboard

Object [object Object] has no method '$set'

Open ndarilek opened this issue 9 years ago • 2 comments

Using your package throughout my app, but I'm hitting a place where the result of a findOne lacks $set.

The code doesn't look particularly interesting, literally just a findOne, a bit of error-checking and an attempt to perform $set on the findOne result. Here it is for completeness' sake (It's in LiveScript):

if from? and to? and Roles.userIsInRole(from, "assistant") and Roles.userIsInRole(to, "client")
  attempt = Attempts.findOne({callId: call._id})
  if attempt?
    task = Tasks.find(attempt.taskId)
    if task?
      console.log("Attempt", attempt)
      attempt.$set({status: "pending"}) // fail

This is the only place I use a $method on a member of the Attempts collection, it works fine on others. The README says that if collections attach their own transforms then they don't get these methods. Is there any way I can check for this? I don't see that I'm doing this anywhere else in my code.

Also, I ran a test in meteor shell and $set appears to be defined on the result of my findOne. Thoughts on what else to try?

Thanks.

ndarilek avatar Jun 04 '15 16:06 ndarilek

That is really odd. When you do that find one and debug it, what is on the prototype chain of the object? And what packages do you have installed?

rclai avatar Jun 05 '15 00:06 rclai

Let me play with this a bit more and get back to you.

I think it might be a transpiler issue and a mismatched line number between the input and transpiled code, and that I might have fixed the issue. Only, a secondary component my app needs is now crashing and I need to poke at that a bit.

So it may be nothing. I'll report back and close soon if so. Thanks for the response!

ndarilek avatar Jun 05 '15 15:06 ndarilek