How to fix a Mongo typo

Hi,
I'm new to mongodb. How would I fix a typo in an object? I tried this query but it resulted in an error of "Unexpected token ILLEGAL"

db.mer22.update({_id:12345},{$set{"yDescription":"Candy"}})

Open in new window

LVL 12
Brandon LyonSenior Frontend DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brandon LyonSenior Frontend DeveloperAuthor Commented:
Rather than update using a $set command I was able to go a different route. I overwrote the entire json entry. This wasn't ideal but it did the trick.

db.mer22.update({_id:12345},{yDescription:"Candy",yColor:"red",ySize:"103"})

Open in new window

aikimarkCommented:
To me, it looks like the original problem might have been the quotes around yDescription.
Brandon LyonSenior Frontend DeveloperAuthor Commented:
If I don't have the quotes around yDescription then the error I get is "SyntaxError: Unexpected token {"

db.mer22.update({_id:12345},{$set{yDescription:"Candy"}})

Open in new window

Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

aikimarkCommented:
Brandon LyonSenior Frontend DeveloperAuthor Commented:
My solution is more of a workaround than an actual solution. It's not even a technically correct solution. Instead of updating a single value, I overwrote all of the values. I'd still like to learn how to update just a single value.
aikimarkCommented:
Please try this.  There needs to be a colon character after the $set
db.mer22.update({_id:12345},{$set: {yDescription : "Candy"}})

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brandon LyonSenior Frontend DeveloperAuthor Commented:
Thank you, that did the trick! I was missing a colon after the set.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.