Separate db logic to db.js