Here's the current situation:
I am tasked with searching in 3 different databases for an ID associated with a shift. Each shift is classified as either an Activity, Food and Beverages, or Other type.
When making the search, the type is provided in the request body.
To handle this, I am using a switch statement to determine which database to search through.
switch(type_shift){
case("activity"):
response = await ActivityShiftDB.findByIdAndUpdate(id_shift, {$pull : {"support": user}}).exec();
break;
case("fandb"):
response = await FoodBeveragesShiftDB.findByIdAndUpdate(id_shift, {$pull : {"support": user}}).exec();
break;
case("other"):
response = await OtherShiftDB.findByIdAndUpdate(id_shift, {$pull : {"support": user}}).exec();
break;
}
However, I feel like this code is not very DRY (Don't Repeat Yourself). Is there a better approach to handling this situation?