mongoexport syntax error message

纵然是瞬间 提交于 2019-11-30 15:08:40

问题


I'm working with mongodb 2.4.3 and I cannot get mongoexport to work. The error message I get with each command is: "JavaScript execution failed: SyntaxError: Unexpected identifier"

At first I thought the problem was with my query parameters, which were long. But find() worked fine with the query so I know that the syntax is ok. I then created a new collection using the query and tried exporting the collection with the following:

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

mongoexport --db Oct2012 --collection sept8subset

In each case, I get "JavaScript execution failed: SyntaxError: Unexpected identifier". Where could that SyntaxError be??

The collection I'm trying to copy has 50,339 objects. In case it is just too big for mongoexport to handle, I took 5 documents out of the collection to make a new collection. I then tried to export them using same command structure as above. I still get the same error message.

Now I'm wondering if the problem is that mongoexport can't work with data involving dates. MongoDB documentation states that I may want to write my own export script using a client driver.

Does anyone have an idea of what my problem is here? Many thanks if you can help out.


回答1:


I found out that running mongoexport from the mongo client--as I was doing--is incorrect. Mongoexport is executed at the command prompt.




回答2:


I ran into this too and I solved it executing the command from the path/bin where 'mongoexport' is located.In my case :

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

"mongoexport -d book -c shelf"

'mongod' is located one step upper from 'mongoimport' , 'mongoexport', etc...



来源:https://stackoverflow.com/questions/16307107/mongoexport-syntax-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!