Skip to content

Commit

Permalink
improve examples
Browse files Browse the repository at this point in the history
  • Loading branch information
googley42 committed Oct 24, 2024
1 parent 4520719 commit acc5a02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object TypeSafeApiAlternateModeling extends DynamoDBLocalSpec {
object Contract {
implicit val schema: Schema.CaseClass5[String, Option[String], Option[String], Boolean, ContractBody, Contract] =
DeriveSchema.gen[Contract]
val (id, identityId, accountId, isTest, body) = ProjectionExpression.accessors[Contract]
val (id, alternateId, accountId, isTest, body) = ProjectionExpression.accessors[Contract]
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import java.time.Instant
import zio.schema.annotation.discriminatorName
import zio.ZIO

/** Demonstrates how to implement the single table pattern (also known as the adjacency lists pattern) using the type-safe API.
* see https://www.alexdebrie.com/posts/dynamodb-single-table/
* see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html
*/
/**
* Demonstrates how to implement the single table pattern (also known as the adjacency lists pattern) using the type-safe API
* using sum and product types.
* see https://www.alexdebrie.com/posts/dynamodb-single-table/
* see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-adjacency-graphs.html
*/
object TypeSafeApiSingleTableSpec extends DynamoDBLocalSpec {


@discriminatorName("userBodyType")
sealed trait UserBody
object UserBody {
Expand Down Expand Up @@ -45,7 +46,7 @@ object TypeSafeApiSingleTableSpec extends DynamoDBLocalSpec {
val (id, selector, userBody) = ProjectionExpression.accessors[User]

// smart constructors manage the id and sort keys

def makeProfile(username: String, fullName: String, email: String, createdAt: Instant): User =
User(s"USER#$username", s"Profile#$username", UserBody.Profile(username, fullName, email, createdAt))

Expand Down

0 comments on commit acc5a02

Please sign in to comment.