I am using aws amplify datastore to connect my app to a dynamodb backend.
I have an Item type which has a property named tags, which is defined as Array of strings
type Item @model {
id: ID!
content: String!
tags: [String]
}
The tags property is not required to be present. But when i save the Item without the tag property,
await DataStore.save(new Item({ content: 'abc' })
DataStore throws this error -
Error: Field tags should be of type string[], object received.null
So i tried saving an empty array when there were no tags
await DataStore.save(new Item({ content: 'abc', tags: [] })
But then dynamodb threw this error when trying to create the item
{
localModel: {
// item content and some extra fields
"tags": Array [],
},
"message": "Supplied AttributeValue is empty, must contain exactly one of the supported datatypes (Service: DynamoDb, Status Code: 400, Request ID: 9AQ0STOFFLGPUGR1S16BTORT8VVV4KQNSO5AEMVJF66Q9ASUAAJG)"
}
How do i save a property which is an array of strings but optional?