Add a mongoexp.sh script.

This commit is contained in:
zkldi
2021-11-26 15:31:09 +00:00
parent 3ab6a078f4
commit 51421c76d6
2 changed files with 26 additions and 0 deletions
+17
View File
@@ -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 <collection> <dbname>";
exit
fi
mongoexport -d "$2" -c "$1" --jsonArray > ../collections/"$1".json
node remove-_id.js
node deterministic-collection-sort.js
+9
View File
@@ -0,0 +1,9 @@
const { IterateCollections } = require("./util");
IterateCollections((data) => {
for (const d of data) {
delete d._id;
}
return data;
});