commonMain.aws.sdk.kotlin.hll.dynamodbmapper.model.internal.TableImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dynamodb-mapper-jvm Show documentation
Show all versions of dynamodb-mapper-jvm Show documentation
High level DynamoDbMapper client
/*
* 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")
}
}