All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.skillw.pouvoir.internal.feature.database.sql.sql.SQLContainerHolder.kt Maven / Gradle / Ivy

The newest version!
package com.skillw.pouvoir.internal.feature.database.sql.sql

import com.skillw.pouvoir.api.feature.database.ContainerHolder
import com.skillw.pouvoir.internal.feature.database.sql.NormalContainer
import com.skillw.pouvoir.internal.feature.database.sql.SQLTable
import com.skillw.pouvoir.internal.feature.database.sql.UserContainer
import taboolib.module.database.ColumnOptionSQL
import taboolib.module.database.ColumnTypeSQL
import taboolib.module.database.Host
import taboolib.module.database.SQL

/**
 * @className SQLContainerHolder
 *
 * @author Glom
 * @date 2023/1/20 17:42 Copyright 2024 Glom.
 */
class SQLContainerHolder(val host: Host) : ContainerHolder, SQL>>() {
    override fun createContainer(
        tableName: String,
        userKey: Boolean,
    ): NormalContainer, SQL> {
        val table = SQLTable(tableName, host)
        if (userKey) {
            table.apply {
                column("username") {
                    type(ColumnTypeSQL.VARCHAR)
                }
                column("key") {
                    type(ColumnTypeSQL.VARCHAR)
                }
                column("value") {
                    type(ColumnTypeSQL.VARCHAR)
                }
            }
            return UserContainer(this, table).apply { createTable() }
        }
        return NormalContainer(this, table)
    }

    override fun disconnect() {
        //TLib会自动断联
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy