Pull all db (mongo) functions into another file to enable easier replacement

Builds on the other PR for using computed ObjectId

@cpennington @singingwolfboy please review or delegate

[looks like I need to rebase]