amplify-backend icon indicating copy to clipboard operation
amplify-backend copied to clipboard

Using a.model() results in a database table for each model, which is an anti pattern of dynamodb

Open mattiLeBlanc opened this issue 3 months ago • 2 comments

Environment information

MacOs 15, Nodejs 22.

Describe the feature

I am not happy with the way you setup a data model using a.model(). It means I can never upgrade my raw graphql schema to this model because I dont want it to create tables for me. I have a mono repo with different stacks that I started way before Amplify Gen 2, probably around 2019. I have perfected my stack and it works well.

I do love the CRUD features the model gives but I would like to be able to control my dynamodb table creation and appsync datasources. Now I am forced to use customTYpe which is not adding any benefit because there is not CRUD created for me.

Is there a plan to allow to define a Type that can be pointing to an existing table? In a real live example, I have a facility table and I have a User table.

Use case

I will have a FAcility and a User type in graphql. But since a user can be part of multiple facilities I have a USER_IN_FACILITY record which I store in the Facility table. I may also have other records stored in the User table that related to user sesison or user devices or who knows. The a.model solution is not offering me anything to deal with more complex models so I am forced to write my own CRUD implentation.

I will not create a model for each type and have a separate table for each. That is a DynamoDb Anti pattern (https://aws.amazon.com/blogs/database/single-table-vs-multi-table-design-in-amazon-dynamodb/)

I think this Gen 2 works great for a ToDo app....but that is not what everyone builds. I have a large scale complex application.

mattiLeBlanc avatar Aug 16 '25 07:08 mattiLeBlanc