1

Here is my document:

{
    $set: {"paths.0.pathBreak" : {

                "1": {
                    "Key1" : [66.92, 22.34],
                    "Key2" : "Val2",
                    "Key3" : [64.92, 22.34],
                    "Key4" : "destination : dest2",
                    "transportTypes" : [{
                        "type" : "bus",
                        "fare" : {
                            "adult" : 5.0,
                            "child" : 2.0,
                            "all" : 5.0
                        },
                        "encodedPath" : "kjfghl2h34h2l4h",
                        "approxTime" : "00:00:30",
                        "info" : "direct "
                    }]  
                }
            }
        }
}

When I assign it to a variable insertDoc through mongodb shell as:

> insertDoc={
... $set: {"paths.0.pathBreak" : {
...
... "1": {
... "Key1" : [66.92, 22.34],
... "Key2" : "Val2",
... "Key3" : [64.92, 22.34],
... "Key4" : "destination : dest2",
... "transportTypes" : [{
... "type" : "bus",
...
Display all 173 possibilities? (y or n)
...         codedPath" : "kjfghl2h34h2l4h",
...               "approxTime" : "00:00:30",
...               "info" : "direct "
...             }]
... }
... }
... }
... }

Why is it not getting assigned to the variable and from where did the line

Display all 173 possibilities? (y or n)

Came from. Could someone figure it out?
Edit: I am actually pasting the document from mongoVUE into the mongo shell.

8
  • you need a var at the beginning to delcare it, though judging by the output you may also have a broken object there Commented Jun 28, 2013 at 11:49
  • @Sammaye I am not running it from javascript.Its from mongo shell. So var not needed.Anyways tried to declare it with var but same result. Commented Jun 28, 2013 at 11:51
  • The Mongo shell IS JavaScript, it is an extend JavaScript shell. But yeah, then it is definitely certain that you probably have an error in the formatting of your input there. Maybe you can show us what insertDoc looks like from where you are inputting it from? Commented Jun 28, 2013 at 11:54
  • @Sammaye "The Mongo shell IS JavaScript"-True. And I have checked all I could regarding the formatting.I could not make out the problem. Commented Jun 28, 2013 at 11:56
  • Can you show us the object in its raw form from where you either pasted or inputted it from? It seems like there might be a hidden character in the initial input. Commented Jun 28, 2013 at 11:57

1 Answer 1

3

Pasting from MongoVue is causing hidden characters which are causing the mongo shell to drop out to the Linux shell during pasting.

Best option is to form it in notepad++ or another program similar and keep new lines out as well.

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.