# -*- mode: shell-script -*- include pretty export DB_NAME="$SERVICE_NAME" ## general type of database (ie: postgres/mysql...) export DB_DATADIR=/var/lib/mongodb export DATA_DIR=$SERVICE_DATASTORE$DB_DATADIR is_db_locked() { is_volume_used "$DATASTORE/${SERVICE_NAME}" } _set_server_db_params() { server_docker_opts+=("-v" "${SERVICE_CONFIGSTORE}/etc/mongod.conf:/etc/mongod.conf" "--add-host" "${SERVICE_NAME}:127.0.0.1") } _set_db_params() { local docker_ip="$1" docker_network="$2" db_docker_opts+=("--network" "$docker_network") db_cmd_opts+=("--host" "$docker_ip") check_command="db.serverStatus().ok" } ddb() { dcmd mongo --quiet "$@"; } mongo:db:ls() { local out if ! out=$(ddb < <(echo "JSON.stringify(db.adminCommand( { listDatabases: 1 } ))")); then err "Could not query list of databases." return 1 fi e "$out" | jq -r '.databases[] | .name' } mongo:db:rename() { local src="$1" dst="$2" out if ! out=$(ddb <