Skip to content

Instantly share code, notes, and snippets.

@kzzzr
Last active August 4, 2021 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzzzr/88757434a13bb7e650735ff0d86360f9 to your computer and use it in GitHub Desktop.
Save kzzzr/88757434a13bb7e650735ff0d86360f9 to your computer and use it in GitHub Desktop.
Export and analyse MongoDB schema to relational view
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# prepare list of databases
declare -a DATABASES=(
"documents"
"communication"
"flights"
)
# loop through databases and generate schemas to yaml files
for db in "${DATABASES[@]}"
do
mongodrdl \
--host=<host_address> \
--port=<port> \
--db=$db \
--username=<username> \
--password=<password> \
--out=./$db.yml \
--sampleSize=10000 # choose number of documents to be sampled
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment