Pass db to model instead of using globals