Closed ahmad-olu closed 2 years ago
Hi @ahmad-olu at this moment, when query, only @belongsTo
nested model will be populated with data. Thank the 3rd of your example schema. When query User
, the User.post
field should be populated with data. For other types of relationship, currently separate queries are required to retrieve nested models.
We are investigating and improving developer experience on associated models operations, please feel free to follow up and to check the progress here: https://github.com/aws-amplify/amplify-flutter/issues/1449.
Can you verify/confirm if the @belongsTo
return expected result for you?
Closing as this is expected given current model generation. Please leave a thumbs up and follow #1449, as @HuiSF suggested, for helping to prioritize better code generation surrounding @hasOne
directives.
Description
I am trying to retrieve data from a 1 to 1 relationship on amplify but its not giving me the data i tired with @hasOne, @belongsTo and i even tried @hasOne with an argument which is @hasOne(fields: ["id"]) the same result
none of it game me the required result i also want to note that when i first save the data the data it returns the data from the relations but when i hot restart and try saving new values the new values are returned but the old relations are not
Categories
Steps to Reproduce
void observeQuery() { _stream = Amplify.DataStore.observeQuery( Post.classType, sortBy: [Post.DATECREATED.descending()], ).listen((event) { setState(() { _posts = event.items; log( _posts .map((e) => '${e.author?.username} ===> ${e.author?.email} ====> ${e.title} =====> ${e.content}') .toString(), ); }); }); }
User {id=12345, username=blackblablabla, email=blackbla@g.com, dateCreated=null, website=null, fullName=null, location=null, bio=null, profileImageUrl=null, following=null, followers=null, createdAt=null, updatedAt=null} (blackblablabla ===> blackbla@g.com ====> This is the second title =====> what is happening, blackblablabla ===> blackbla@g.com ====> This is the second title =====> what is happening, null ===> null ====> This is the First title =====> seriously r this, null ===> null ====> This is the First title =====> seriously r this)
Dependencies
Device
samsung Ao2s
OS
Android 11
Deployment Method
Amplify CLI
CLI Version
9.2.1
Additional Context
No response
Amplify Config
{ "version": "1" }