Menu

Put the Mongo-to-SQL toggle at the contract, not inside the shared package
📰

Put the Mongo-to-SQL toggle at the contract, not inside the shared package

DEV Community: azure·Tummala Krishna Kishore·3 days ago
#c4xxJbMx
#devtoazure#devto#dev#mongo#contract
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.