I'm recently writing a flutter app which I need to manipulate the data in Amplify datastore. I'm able to query data by regular data type(e.g. String), but I'm not sure how to query by an array of custom type data.
Here is an example of my data model
type Shop @model {
id: ID!
owner: String
item: [Item]
}
type Item{
name: String
color: String
}
How can I get a list of all Shop Models that have an Item named "abc", no matter what color it is.
I have done something like this, using the predicate "contains", but seems that it's not the right way to do so:
Future <List<Shop>> getShops(String itemName) async{
try{
final shops = await Amplify.Datastore.query(
Shop.classType,
where: Shop.ITEM.name.contains(itemName)
);
return shops;
} catch (e){
throw e;
}
}