2013-04-30 85 views
8

我正在使用mongodb 2.4.3,我無法讓mongoexport工作。我得到每個命令的錯誤消息是: "JavaScript execution failed: SyntaxError: Unexpected identifier"mongoexport語法錯誤消息

起初我以爲問題是我的查詢參數,這是很長的。但find()在查詢中正常工作,所以我知道語法正常。然後,我創建使用查詢一個新的集合,並試圖用下面的出口集合:

mongoexport --db Oct2012 --collection sept8subset --csv --fields "text","created_at","user.screen_name","user.followers_count" --out sept8.csv

mongoexport --db Oct2012 --collection sept8subset --csv --fields text,created_at,user.screen_name,user.followers_count --out sept8.csv

mongoexport -d Oct2012 -c sept8subset --csv --fields text,created_at,user.screen_name -o sept8.csv

mongoexport --db Oct2012 --collection sept8subset --dbpath ~/db (should need dbpath as mongod instance is running)

mongoexport --db OCt2012 -collection sept8subset -o sept8.txt

​​

在每種情況下,我得到"JavaScript execution failed: SyntaxError: Unexpected identifier"。 SyntaxError在哪裏?

我試圖複製的集合有50,339個對象。如果它對於mongoexport來說太大了,我會從這個集合中抽出5個文檔來創建一個新的集合。然後我嘗試使用與上面相同的命令結構導出它們。我仍然收到相同的錯誤信息。

現在我想知道如果問題是,mongoexport不能處理涉及日期的數據。 MongoDB文檔聲明我可能想使用客戶端驅動程序編寫自己的導出腳本。

有沒有人知道我的問題在這裏?非常感謝,如果你能幫忙。

回答

17

我發現從mongo客戶端運行mongoexport - 正如我所做的那樣 - 是錯誤的。 Mongoexport在命令提示符下執行。

1

我跑進這也和我解決它從路徑/ bin中執行命令,其中「mongoexport」是located.In我的情況:

my_path: /usr/local/Cellar/mongodb/2.4.4-x86_64/bin 

"mongoexport -d book -c shelf" 

「的mongod」位於上一個步驟'mongoimport','mongoexport'等...

+0

感謝您的回覆。看着它幫我弄清了我的錯誤。 – SCallan 2013-07-09 00:41:17