Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Multi-tenancy Transforms info #52

Merged
merged 2 commits into from
Sep 11, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/src/docs/asciidoc/multiTenancy/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This type of architecture is highly common in Software as a Service (SaaS) and C

include::modes.adoc[]

=== Multi-Tenancy Transformations

include::tenantTransforms.adoc[]

=== Database Per Tenant

include::databasePerTenant.adoc[]
Expand Down
38 changes: 38 additions & 0 deletions docs/src/docs/asciidoc/multiTenancy/tenantTransforms.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
The next transformations can be applied to any class to simplify greatly the development of Multi-Tenant applications. These include:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other commit. Please use "The following..."


- `@CurrentTenant` - Resolve the current tenant for the context of a class or method
- `@Tenant` - Use a specific tenant for the context of a class or method
- `@WithoutTenant` - Execute logic without a specific tenant (using the default connection)

For example:

[source,groovy]
----
import grails.gorm.multitenancy.*

// resolve the current tenant for every method
@CurrentTenant
class TeamService {

// execute the countPlayers method without a tenant id
@WithoutTenant
int countPlayers() {
Player.count()
}

// use the tenant id "another" for all GORM logic within the method
@Tenant({"another"})
List<Team> allTwoTeams() {
Team.list()
}

List<Team> listTeams() {
Team.list(max:10)
}

@Transactional
void addTeam(String name) {
new Team(name:name).save(flush:true)
}
}
----