We are moving a feature from MongoDB to SQL. One team owns the Mongo side. A different team owns the SQL side. Both want the same common package and the same Function App, with as little code change as possible, and a simple toggle to switch between them.
The obvious design is an if (useSql) somewhere. The question is where it lives. I think most people put it in the wrong place.
The tempting spot
The tempting spot is inside the shared package. One OrderService , one repository class, and a flag that picks the Mongo driver or the SQL client halfway down the call. It feels minimal. One file changes.
It is also the version where two teams edit the same class. The Mongo team knows nothing about your SQL joins. The SQL team has never seen your aggregation pipeline.…