得到"失踪;在陈述之前#34;尝试在mongodb shell中使用eval时出错

时间:2017-01-26 09:56:20

标签: javascript mongodb shell

enter image description here

我想尝试从mongo shell执行javascript。 mongo test --eval" printjson(db.getCollectionNames())"

但是,我在上面的屏幕截图中看到了错误。

1 个答案:

答案 0 :(得分:1)

{ - 3}}中使用了“--eval”选项,您不应该已经连接到shell。使用它,如下例所示:

mongo YOUR_DB_NAME --eval "printjson(db.getCollectionNames())"