#✅ - How to set a default value for a column in DyanmoDB created using Amplify Serverless API

1 messages · Page 1 of 1 (latest)

swift folio
#
C:\Users\Laila\Desktop\amplify-api>amplify add storage
? Select from one of the below mentioned services: NoSQL Database

Welcome to the NoSQL DynamoDB database wizard
This wizard asks you a series of questions to help determine how to set up your NoSQL database table.

√ Provide a friendly name · testapitable
√ Provide table name · apiTable

You can now add columns to the table.

√ What would you like to name this column · id
√ Choose the data type · string
√ Would you like to add another column? (Y/n) · yes
√ What would you like to name this column · username
√ Choose the data type · string
√ Would you like to add another column? (Y/n) · yes
√ What would you like to name this column · email
√ Choose the data type · string
√ Would you like to add another column? (Y/n) · yes
√ What would you like to name this column · password
√ Choose the data type · string
√ Would you like to add another column? (Y/n) · yes
√ What would you like to name this column · isAdmin
√ Choose the data type · boolean
√ Would you like to add another column? (Y/n) · no

√ Choose partition key for the table · id
√ Do you want to add a sort key to your table? (Y/n) · no

√ Do you want to add global secondary indexes to your table? (Y/n) · no
√ Do you want to add a Lambda Trigger for your Table? (y/N) · no
:white_check_mark: Successfully added resource testapitable locally

here I created the dynamoDB table with above config in amplify, now I want to add default value for isAdmin. Any idea how to do that?

spare meteor
#

Hi @swift folio currently, this isn't supported by Amplify or by DynamoDB. The solution for this would be to define some logic at the resolver or client level when creating a new item and specify a value if one is not defined.

vocal chasmBOT
#

✅ - How to set a default value for a column in DyanmoDB created using Amplify Serverless API