add table prefix and suffix for multi-tenant environment support

This closes #125.
This commit is contained in:
fourdim 2022-03-16 22:47:34 +08:00
parent c29f0afd2b
commit 87cc6c9e93
9 changed files with 100 additions and 0 deletions

View file

@ -51,6 +51,16 @@ func (a FilmTable) FromSchema(schemaName string) *FilmTable {
return newFilmTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new FilmTable with assigned table prefix
func (a FilmTable) WithPrefix(prefix string) *FilmTable {
return newFilmTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new FilmTable with assigned table suffix
func (a FilmTable) WithSuffix(suffix string) *FilmTable {
return newFilmTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newFilmTable(schemaName, tableName, alias string) *FilmTable {
return &FilmTable{
filmTable: newFilmTableImpl(schemaName, tableName, alias),