diff --git a/database-seeds/scripts/mongoexp.sh b/database-seeds/scripts/mongoexp.sh new file mode 100755 index 000000000..9972a1ace --- /dev/null +++ b/database-seeds/scripts/mongoexp.sh @@ -0,0 +1,17 @@ +#! /bin/bash + +# Exports data from a mongodb instance back to the collections +# folder. +# Useful for backporting updates, or something. + +cd "$(dirname "${BASH_SOURCE[0]}")" || exit + +if [ -z "$1" ] || [ -z "$2" ]; then + echo "Usage: mongoexp.sh "; + exit +fi + +mongoexport -d "$2" -c "$1" --jsonArray > ../collections/"$1".json + +node remove-_id.js +node deterministic-collection-sort.js \ No newline at end of file diff --git a/database-seeds/scripts/remove-_id.js b/database-seeds/scripts/remove-_id.js new file mode 100644 index 000000000..76fa681fb --- /dev/null +++ b/database-seeds/scripts/remove-_id.js @@ -0,0 +1,9 @@ +const { IterateCollections } = require("./util"); + +IterateCollections((data) => { + for (const d of data) { + delete d._id; + } + + return data; +});