How to execute mongo commands through shell

Lets say you need to find out which is the primary node in the mongo cluster in your shell script,

mongo –host 10.126.71.162 –username=userid –password=secret –eval “db.runCommand(‘ismaster’).primary”

This would quickly open the mongo shell and execute the commands, and give the output as the last line

MongoDB shell version v4.0.5
connecting to: mongodb://10.126.71.162:27017/?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“65f2e5ab-aa97-4306-8a20-afd70a4ceeb0”) }
MongoDB server version: 4.0.5
10.126.71.162:27017

Dynamodb: How to run dynamodb locally

DynamoDb is a cloud managed server provided by AWS – Amazon web service. Technically, you cannot install and manage it on your own for your production system. However for testing purpose, AWS provides the ways to run it locally and avoid hitting cloud service all the time to save some money.
The easiest way is to pull docker image and run it locally
Follow below steps to run dynamodb locally
# pull image from docker hub provided by AWS – https://hub.docker.com/r/amazon/dynamodb-local/

docker pull amazon/dynamodb-local
# run image
docker run -p 8000:8000 amazon/dynamodb-local
Hit this url on browser  to test dynamodb is working