Migrating existing code to use mongoose