2013-06-28 17 views
1

這裏是我的文檔:MongoDB中變量不成功的宣言殼

{ 
    $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 " 
        }] 
       } 
      } 
     } 
} 

當我把它分配給一個變量insertDoc通過MongoDB的外殼爲:

> 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 " 
...    }] 
... } 
... } 
... } 
... } 

爲什麼沒有得到分配給變量和從哪裏行

Display all 173 possibilities? (y or n) 

來自。有人能弄明白嗎?
編輯: 我實際上是將文件從mongoVUE粘貼到mongo shell中。

+0

你需要一個'var'在開始delcare它,雖然通過輸出判斷你可能也有一個破損的對象 – Sammaye

+0

@Sammaye我沒有從mongo shell的javascript.Its運行它。所以var不需要。總是嘗試用var聲明它,但結果相同。 – rahulserver

+0

Mongo shell是JavaScript,它是一個擴展的JavaScript shell。但是,那肯定肯定的是,你可能在輸入的格式上存在錯誤。也許你可以告訴我們從輸入的地方看insertDoc的樣子? – Sammaye

回答

3

從MongoVue粘貼導致隱藏字符,導致mongo shell在粘貼期間退出到Linux shell。

最好的選擇是在記事本++或其他類似的程序中形成它,並保留新的行。