What is wrong with this MongoDB Update?


#1

I haven’t located a truly clear example of syntax for a MongoDB Update function, but I tried this:

'updateJobLocation': function(username, jobLoc, placename, st8OrProvince, postalcode, xcoord, ycoord) {
    JobLocations.update( {jl_username: username },
      { $set:  { jl_jobloc: jobLoc, jl_placename: placename, jl_st8OrProvince: st8OrProvince,
        jl_postalcode: postalcode, jl_xcoord: xcoord, jl_ycoord: ycoord } }
    });
},

It fails; I get:

W20150926-21:36:33.940(-7)? (STDERR) C:\Meteor\scheduler.meteor\local\build\pro
grams\server\app\both\methods.js:29
W20150926-21:36:33.941(-7)? (STDERR) });
W20150926-21:36:33.941(-7)? (STDERR) ^
W20150926-21:36:33.942(-7)? (STDERR) SyntaxError: Unexpected token }

I changed the code slightly (removed one of the "}"s), to this:

'updateJobLocation': function(username, jobLoc, placename, st8OrProvince, postalcode, xcoord, ycoord) {
    JobLocations.update( {jl_username: username },
      { $set:  { jl_jobloc: jobLoc, jl_placename: placename, jl_st8OrProvince: st8OrProvince,
        jl_postalcode: postalcode, jl_xcoord: xcoord, jl_ycoord: ycoord }
      });
},

…and now it complains this way:

W20150926-21:56:10.677(-7)? (STDERR) C:\Meteor\scheduler.meteor\local\build\pro
grams\server\app\both\methods.js:49
W20150926-21:56:10.678(-7)? (STDERR) { w_username: username, w_workerid:
workerid },
W20150926-21:56:10.678(-7)? (STDERR) ^
W20150926-21:56:10.678(-7)? (STDERR) SyntaxError: Unexpected token {

What’s the beef?


#2

Collection.update({},{$set: {}})

and most likely your other method has syntax issues, look at error msg, it is different lines


#3

I’m not seeing a difference between my code and yours. And I don’t see how my code does not follow the syntax given, expressly:

Collection.update({},{$set: {}})

So…“All down but nine, set 'em up on the other alley, pard.”


#4

Maybe this is what you were trying to say, but that code was actually fine; other update code had a superfluous “{” at the beginning of the update() call. It’s running again.


#5

That’s what I wrote:) check your other method