Comments (2)
@frederikhors I'm sorry for the late reply, and thank you for giving me a question.
Where do you think I should do something like below? In handler, usecase or repository?
First, I think the point is your application boundary.
Regarding a multi-tenancy application, the data referred by API are always bounded by specified tenant. Thus I think the handler has a responsibility to solve the boundary of the application, because of the layer below handler doesn't want to have a concerning about any other tenant.
The domain (and usecase) layer should solve an application concerning of specified tenant simply.
I think maybe the concept of FilterByTenant in the usecase layer is an unnecessary repetition and should belong to lower levels like repositories?
Yes, I think better to put FilterByTenant to the repository.
You can inject tenant_id to repository when it is initialized like following.
repo := NewUserRepository(ctx, tenant_id)
But, I think better to treat tenant_id as a context data.
I said the multi-tenancy application's tenant_id is to solve application boundary, I think it is the same as an application context data.
So, I will try to implement FilterByTenant as following:
repo := NewUserRepository(ctx)
---
type UserRepository strurct {
ctx context.Context
}
func (r *UserRepository) FilterByTenant() *Users {
tenant_id := ctx.Value('tenant_id')
...
}
from 8am.
I close this, thanks.
from 8am.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 8am.