1

Am trying to run this simple query and am getting

"SyntaxError: Unexpected token ILLEGAL".

db.Bookdetail.insert({
      "Subject":"Book Details",
      "Details": [
        {
          "Book Id":"001",
          "Book Name":"C# step by step",
          "Book Description":"Programming book on C#"
        },
        {
          "Book Id":"002",
          "Book Name":"Head First Java",
          "Book Description":"Programming Book on Java"
        }, 
        {
          "Book Id":"003",
          "Book Name":"Steve Jobs",
          "Book Description":"biography of Jobs"
        }
      ]
    });
1
  • it seems you copied the query from invalid source, the colon character is not proper. Commented Feb 24, 2016 at 7:52

2 Answers 2

3

It seems that the : in "Book Id":"001" is invalid. Per your code, the in "Book Id":"001" is full width letter, which is invalid character for JS

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

2 Comments

Hi it's not invalid. I have entered the same format many times. There is some other minor issue. cannot find it.
@Bramenath, per the code posted in your question the : of "Book Id":"001" is different with the : of "Subject":"Book Details" obviously. please check it again.
0

please use this code.

db.Bookdetail.insert({
      "Subject":"Book Details",
      "Details": [
        {
          "Book Id":"001",
          "Book Name":"C# step by step",
          "Book Description":"Programming book on C#"
        },
        {
          "Book Id":"002",
          "Book Name":"Head First Java",
          "Book Description":"Programming Book on Java"
        }, 
        {
          "Book Id":"003",
          "Book Name":"Steve Jobs",
          "Book Description":"biography of Jobs"
        }
      ]
    });

It seems you copied query form the source, it has invalid character.

Thanks

1 Comment

@Bramenath please mark the answers and correct mark so that community can follow the right answers straight away.

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.