Full code with MongoDB.