1

I am new to MongoDB and currently I am learning it. But at a point I got syntax error and I unable to find out that error. So, I need your help.

Code:

let reviewText1: [
    "The Martian could have been a sad drama file, instead it was a ",
    "hilarious file weith a little bit of dra,a added to it. The Martian is what ",
    "everybody wants from a space adventure. Ridley Scott can still make great ",
    "movies and this is one of his best."
].join() db.movieDetails.updateOne({
        title:"The Martian"
    }, {
        $push: {
            reviews: {
                rating: 4.5,
                date: ISODate("2016-01-12T09:00:00Z"),
                reviewer: "Spencer H.",
                text: reviewText1
            }
        }
    })

Error:

2020-02-03T08:29:30.381+0530 E QUERY [js] uncaught exception: SyntaxError: u nexpected token: ':' : @(shell):1:15

Thanks In Advance.

1 Answer 1

1

You cannot use colon after variable name in JavaScript, there should be:

let reviewText1 = [
    "The Martian could have been a sad drama file, instead it was a ",
    "hilarious file weith a little bit of dra,a added to it. The Martian is what ",
    "everybody wants from a space adventure. Ridley Scott can still make great ",
    "movies and this is one of his best."
].join()

console.log(reviewText1)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.