DoSomething/ds-mdata-responder — pull request #75 by jonuy (2014-07-15 23:43:23+00:00)
Title: Creating a single mongo connection that models get created off of

#### What's this PR do?
Instead of new Mongo connections getting created with each request, a single connection is created once and used to create all Mongoose models needed.

#### Where should the reviewer start?
`app.getModel()` is a helper function created to get or create Mongoose models as needed. This replaces all `db.createConnection` + `db.model` calls throughout the code base.

#### How should this be manually tested?
I was able to reproduce the error before by POSTing to http://localhost:4711/game/create?type=competitive-story with parameters:
```
story_id=1
person[first_name]=jon
person[phone]=13015550100
friends[0][first_name]=friend0
friends[1][first_name]=friend1
friends[2][first_name]=friend2
friends[0][phone]=13015550101
friends[1][phone]=13015550102
friends[2][phone]=13015550103
```
... probably like 50 times in a row. If you watch the mongo logs before this change, you'll see new connections getting created on each POST. Once it gets to around connection 204, it errors out. After this change though, each new POST should not show any new connection.

#### Any background context you want to provide?
@desmondmorris All those Mobile Common errors about connections getting refused - I'm pretty sure it's this.

#### What are the relevant tickets?
Fixes DoSomething#74