How to Operate MongoDB through shell Scripts

  mongodb, question

Automate MongoDB with shell Scripts

Run the written. / script
It was found that the mongo link could be established, but the second link could not be started.

The script reads as follows

mongo WordPress
show collections

I don’t know why.

The mongo shell statement starts from the second one, and of course it cannot be run.

This should be the case:

mongo WordPress --eval "show collections;db.posts.find().limit(10);"