#! /bin/bash

port=57017

if false && ! curl -sS localhost:$port > /dev/null; then
   prefix=/tmp/whodunit.db
   mkdir -p $prefix/data
   mongod \
      --dbpath $prefix/data \
      --logpath $prefix/log \
      --pidfilepath $prefix/pid \
      --port $port \
      --fork
fi

mshell() {
   mongo \
      --quiet \
      --port $port \
      --eval "$*"
}

remove() {
   mshell \
      'db.getSiblingDB("db")["col"].remove({})'
}

export DBURI=${DB_URI:-"mongodb://localhost:$port"}

export DRIVERTYPE=boltdb
export DBURI=$(mktemp)
