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

commonMain.aws.sdk.kotlin.hll.dynamodbmapper.model.internal.TableImpl.kt Maven / Gradle / Ivy

There is a newer version: 1.3.73-beta
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */
package aws.sdk.kotlin.hll.dynamodbmapper.model.internal

import aws.sdk.kotlin.hll.dynamodbmapper.DynamoDbMapper
import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema
import aws.sdk.kotlin.hll.dynamodbmapper.model.Index
import aws.sdk.kotlin.hll.dynamodbmapper.model.Table
import aws.sdk.kotlin.hll.dynamodbmapper.model.TableSpec
import aws.sdk.kotlin.hll.dynamodbmapper.operations.TableOperations
import aws.sdk.kotlin.hll.dynamodbmapper.operations.TableOperationsImpl

internal fun  tableImpl(
    mapper: DynamoDbMapper,
    name: String,
    schema: ItemSchema.PartitionKey,
): Table.PartitionKey {
    val tableName = name // shadowed below
    val specImpl = TableSpecPartitionKeyImpl(mapper, tableName, schema)
    val opsImpl = TableOperationsImpl(specImpl)
    return object :
        Table.PartitionKey,
        TableSpec.PartitionKey by specImpl,
        TableOperations by opsImpl {

        override fun  getIndex(
            name: String,
            schema: ItemSchema.PartitionKey,
        ): Index.PartitionKey = indexImpl(mapper, tableName, name, schema)

        override fun  getIndex(
            name: String,
            schema: ItemSchema.CompositeKey,
        ): Index.CompositeKey = indexImpl(mapper, tableName, name, schema)

        override suspend fun getItem(partitionKey: PK) = TODO("not yet implemented")
    }
}

internal fun  tableImpl(
    mapper: DynamoDbMapper,
    name: String,
    schema: ItemSchema.CompositeKey,
): Table.CompositeKey {
    val specImpl = TableSpecCompositeKeyImpl(mapper, name, schema)
    val opsImpl = TableOperationsImpl(specImpl)
    return object :
        Table.CompositeKey,
        TableSpec.CompositeKey by specImpl,
        TableOperations by opsImpl {

        override fun  getIndex(
            name: String,
            schema: ItemSchema.PartitionKey,
        ): Index.PartitionKey = indexImpl(mapper, tableName, name, schema)

        override fun  getIndex(
            name: String,
            schema: ItemSchema.CompositeKey,
        ): Index.CompositeKey = indexImpl(mapper, tableName, name, schema)

        override suspend fun getItem(partitionKey: PK, sortKey: SK) = TODO("Not yet implemented")
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy