76 lines
3.7 KiB
Kotlin
76 lines
3.7 KiB
Kotlin
package ru.landgrafhomyak.db.serdha0.api.module
|
|
|
|
import ru.landgrafhomyak.db.raw_sql_skeleton.Table
|
|
import ru.landgrafhomyak.db.serdha0.api.queries._Query
|
|
import ru.landgrafhomyak.db.raw_sql_skeleton.TableConstructor
|
|
import ru.landgrafhomyak.serdha0.api.module.Namespace
|
|
|
|
/**
|
|
* Scope methods for creating new [module template][ModuleTemplate].
|
|
*
|
|
* @see ModuleTemplate.CreateModuleTemplatesScope.createTemplate
|
|
* @see ModuleTemplate.ModuleCreator.createSchema
|
|
*/
|
|
public interface CreateModuleScope {
|
|
public val rootNs: Namespace
|
|
|
|
/**
|
|
* Creates table in [specified namespace][namespace] with [specified name][name] and stores it in the database.
|
|
* If table was created by previous synchronizations, asserts that table at the specified path in the database is same as table provided by [initializer].
|
|
*
|
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] this table must be [kept][UpgradeModuleScope.upgradeTable] (or [renamed][UpgradeModuleScope.renameTable]) or [deleted][UpgradeModuleScope.deleteTable].
|
|
*
|
|
* @param tUE User's type for containing table-related descriptors.
|
|
* @param namespace Way to group tables if there is a lot.
|
|
* @param name Name of table for debugging.
|
|
* @param initializer Table-related descriptors initializer.
|
|
* @return Table descriptor.
|
|
*/
|
|
public fun <tUE : Any> createTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
|
|
|
|
/**
|
|
* Creates a temporary table that exits only until connection to the database not [closed][SynchronizedDatabase._close].
|
|
*
|
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
*
|
|
* @param tUE User's type for containing table-related descriptors.
|
|
* @param namespace Way to group tables if there is a lot.
|
|
* @param name Name of table for debugging.
|
|
* @param initializer Table-related descriptors initializer.
|
|
* @return Table descriptor.
|
|
*/
|
|
public fun <tUE : Any> createSessionScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
|
|
|
|
/**
|
|
* Creates a temporary table that exits only inside [transaction][Transaction] and auto-deleted (or cleared, depends on driver implementation) when it [finished][Transaction._assertTransactionFinishedAndReleaseResources].
|
|
*
|
|
* On [module upgrading][ModuleTemplate.CreateModuleTemplatesScope.upgradeTemplate] must be recreated if needed.
|
|
*
|
|
* @param tUE User's type for containing table-related descriptors.
|
|
* @param namespace Way to group tables if there is a lot.
|
|
* @param name Name of table for debugging.
|
|
* @param initializer Table-related descriptors initializer.
|
|
* @return Table descriptor.
|
|
*/
|
|
public fun <tUE : Any> createTransactionScopeTemporaryTable(namespace: Namespace = this.rootNs, name: String, initializer: TableConstructor<tUE>): Table<tUE, Nothing>
|
|
|
|
public val queries: _Query.Constructor.Scope
|
|
|
|
public val temporarySubqueries: _Query.Constructor.Scope
|
|
|
|
public val moduleConfiguringTemporaryQueries: _Query.Constructor.Scope
|
|
|
|
public fun <qUE : Any> createQuery(creator: _Query.Constructor<qUE>): qUE
|
|
|
|
public fun <qUE : Any> createModuleConfiguringTemporaryQuery(creator: _Query.Constructor<qUE>): qUE
|
|
|
|
/**
|
|
* Replaces [specified namespace][rootNs] with schema provided by [template].
|
|
* [This namespace][rootNs] will be root namespace for module and shouldn't contain any other definitions.
|
|
*
|
|
* @param rootNs Namespace where the new module will be located.
|
|
* @param template Schema template.
|
|
* @return Module descriptor.
|
|
*/
|
|
public fun <mUE : Any> substituteModule(rootNs: Namespace, template: ModuleTemplate<mUE>): Module<mUE>
|
|
} |