9

I am getting the above error in Mongo DB when entering the following in the shell but I can't for the life of me see where there is a syntax error...

db.createUser (
... "user":"dbTest",
... "pwd":"testPass",
... "roles": [
... { "role":"readWrite", "db":"test" }
... ]
... )

That has been copied and pasted directly from the console.

1 Answer 1

5

You're missing curly braces around the object literal:

db.createUser ({
    "user":"dbTest",
    "pwd":"testPass",
    "roles": [
    { "role":"readWrite", "db":"test" }
    ]
    })

See db.createUser() - Examples

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

2 Comments

I get the same error when running rocky26 = Movie.create(title: "Rocky XXVI") I tried passing { } and still didn't work. According to the documentation that is the right way to do it. Model.create
@StevenAguilar I'm sure you have figured it out by now but I think you should have had Movie.create({"title": "Rocky XXVI"})

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.