MongoDB: Parameterize the DB client to use for each operation, in preparation for threading.
MongoDB: Move connection-establishing code to its own function.