Skip to content

Single Table Design: Support Patterns #568

Description

@bmalinconico

Hello,

I wanted to have a conversation as to how, and if at all, Dynamoid supports the common single table design for DynamoDB.

The basic TL;DR; is the existing STI with some Range Key magic. The Hash Key represents the ability to get all of a common thing, I'm going to use Pizza with a kinda contrived example.

PizzaId(HK) ResourceId (RK) type (Required for Deserialization) Name Cost Quantity LeftHalf RightHalf
a pizza Pizza Combo 13.99
a topping-onions PizzaTopping Onion Heavy true true
a topping-peperoni PizzaTopping Peperoni Light false true

This breaks down with the Dynamoid STI implementation.

I'd like to open a conversation about updating the ORM to allow for this pattern and want to toss around some options then identify what would need to be updated to work.

You can query for all toppings on a pizza by using Pizza ID and RK Prefix

First Idea

Allow a range prefix to be specified

class PizzaTopping
  range :resource_id, prefix_on_persistance: "topping-"
end

# There is also a need to "fix" the RK for single instance objects
class Pizza
  range :resource_id, fixed_value: "pizza"
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions