PynamoDB Single Table Design OrgsAndUsers

663 Views Asked by At

I am trying to create this single table using pynamodb:

enter image description here

This is what I have for the OrgModel:

TABLE_NAME = 'OrgsAndUsers'


class OrgModel(Model):
    class Meta:
        table_name = TABLE_NAME
        region = 'us-east-1'
    OrgName = UnicodeAttribute(hash_key=True, range_key=True)
    SubscriptionLevel = UnicodeAttribute()

How do I model the User object? How do I set OrgModel as the User's partition key?

Is pynamodb a good package to use for dynamodb programming in python?

1

There are 1 best solutions below

0
On

I think what you're looking to do is

class UserModel(Model):
    class Meta:
        table_name = 'OrgsAndUsers'
        region = 'us-east-1'
    org_name = UnicodeAttribute(hash_key=True)
    user_name = UnicodeAttribute(range_key=True)
    subscription_level = UnicodeAttribute()
    role = UnicodeAttribute()