-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deleting data from local datastore when connect to internet to sync #5806
Comments
the add methods for all of them Future _saveMainAccount() async {
################################# Future _saveSubAccount() async {
} ######################################## Future _handleSave() async {
} |
Did you configure Amplify with Gen1 + Conflict Detection enabled. Your models appear to be missing createdAt, updatedAt, and version variables which are all required for DataStore to work successfully? If conflict detection was enabled on your project, try regenerating your models. Maybe they were generated before it was enabled? |
#tylerjroach thanks alot for the quick response |
Did you enable it after my last message or was it already enabled? Please post your updated models so that we can make sure that they were generated correctly. |
it was already enabled before i opened the issue here is my model i will post them in the following comment |
mainAccount model /*
// NOTE: This file is generated and may not follow lint rules defined in your app // ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; /** This is an auto generated class representing the MainAccount type in your schema. */ @OverRide @deprecated('[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') MainAccountModelIdentifier get modelIdentifier { String? get mainAccountName { String? get userName { String? get details { String? get icon { String? get defaultCurrency { int get isDeleted { List? get subAccounts { amplify_core.TemporalDateTime? get createdAt { amplify_core.TemporalDateTime? get updatedAt { const MainAccount._internal({required this.id, mainAccountName, userName, details, icon, defaultCurrency, required isDeleted, subAccounts, createdAt, updatedAt}): _mainAccountName = mainAccountName, _userName = userName, _details = details, _icon = icon, _defaultCurrency = defaultCurrency, _isDeleted = isDeleted, _subAccounts = subAccounts, _createdAt = createdAt, _updatedAt = updatedAt; factory MainAccount({String? id, String? mainAccountName, String? userName, String? details, String? icon, String? defaultCurrency, required int isDeleted, List? subAccounts}) { bool equals(Object other) { @OverRide @OverRide @OverRide
} MainAccount copyWith({String? mainAccountName, String? userName, String? details, String? icon, String? defaultCurrency, int? isDeleted, List? subAccounts}) { MainAccount copyWithModelFieldValues({ MainAccount.fromJson(Map<String, dynamic> json) Map<String, dynamic> toJson() => { Map<String, Object?> toMap() => { static final amplify_core.QueryModelIdentifier MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier();
}); class _MainAccountModelType extends amplify_core.ModelType { @OverRide @OverRide /**
/** Create an instance of MainAccountModelIdentifier using [id] the primary key. */ @OverRide @OverRide @OverRide @OverRide @OverRide
} @OverRide |
subAccount model
// NOTE: This file is generated and may not follow lint rules defined in your app // ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; /** This is an auto generated class representing the SubAccount type in your schema. */ @OverRide @deprecated('[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') SubAccountModelIdentifier get modelIdentifier { MainAccount? get mainAccount { String? get subAccountName { String? get defaultCurrency { String? get userName { String? get image { String? get phoneNumber { String? get whatsAppNumber { String? get address { String? get note { MessagingWay? get messagingWay { MessagingType? get messagingType { int get isDeleted { List? get debtOperations { amplify_core.TemporalDateTime? get createdAt { amplify_core.TemporalDateTime? get updatedAt { const SubAccount._internal({required this.id, mainAccount, subAccountName, defaultCurrency, userName, image, phoneNumber, whatsAppNumber, address, note, messagingWay, messagingType, required isDeleted, debtOperations, createdAt, updatedAt}): _mainAccount = mainAccount, _subAccountName = subAccountName, _defaultCurrency = defaultCurrency, _userName = userName, _image = image, _phoneNumber = phoneNumber, _whatsAppNumber = whatsAppNumber, _address = address, _note = note, _messagingWay = messagingWay, _messagingType = messagingType, _isDeleted = isDeleted, _debtOperations = debtOperations, _createdAt = createdAt, _updatedAt = updatedAt; factory SubAccount({String? id, MainAccount? mainAccount, String? subAccountName, String? defaultCurrency, String? userName, String? image, String? phoneNumber, String? whatsAppNumber, String? address, String? note, MessagingWay? messagingWay, MessagingType? messagingType, required int isDeleted, List? debtOperations}) { bool equals(Object other) { @OverRide @OverRide @OverRide
} SubAccount copyWith({MainAccount? mainAccount, String? subAccountName, String? defaultCurrency, String? userName, String? image, String? phoneNumber, String? whatsAppNumber, String? address, String? note, MessagingWay? messagingWay, MessagingType? messagingType, int? isDeleted, List? debtOperations}) { SubAccount copyWithModelFieldValues({ SubAccount.fromJson(Map<String, dynamic> json) Map<String, dynamic> toJson() => { Map<String, Object?> toMap() => { static final amplify_core.QueryModelIdentifier MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier();
}); class _SubAccountModelType extends amplify_core.ModelType { @OverRide @OverRide /**
/** Create an instance of SubAccountModelIdentifier using [id] the primary key. */ @OverRide @OverRide @OverRide @OverRide @OverRide
} @OverRide |
deptoperation model
// NOTE: This file is generated and may not follow lint rules defined in your app // ignore_for_file: public_member_api_docs, annotate_overrides, dead_code, dead_codepublic_member_api_docs, depend_on_referenced_packages, file_names, library_private_types_in_public_api, no_leading_underscores_for_library_prefixes, no_leading_underscores_for_local_identifiers, non_constant_identifier_names, null_check_on_nullable_type_parameter, override_on_non_overriding_member, prefer_adjacent_string_concatenation, prefer_const_constructors, prefer_if_null_operators, prefer_interpolation_to_compose_strings, slash_for_doc_comments, sort_child_properties_last, unnecessary_const, unnecessary_constructor_name, unnecessary_late, unnecessary_new, unnecessary_null_aware_assignments, unnecessary_nullable_for_final_variable_declarations, unnecessary_string_interpolations, use_build_context_synchronously import 'ModelProvider.dart'; /** This is an auto generated class representing the DebtOperation type in your schema. */ @OverRide @deprecated('[getId] is being deprecated in favor of custom primary key feature. Use getter [modelIdentifier] to get model identifier.') DebtOperationModelIdentifier get modelIdentifier { SubAccount? get subAccount { String? get userName { double get moneyAmount { String? get wholeSaleAmount { String? get retailAmount { String? get currency { String? get details { OperationType? get operationType { amplify_core.TemporalDateTime? get addDateTime { int? get isDeleted { amplify_core.TemporalDateTime? get createdAt { amplify_core.TemporalDateTime? get updatedAt { const DebtOperation._internal({required this.id, subAccount, userName, required moneyAmount, wholeSaleAmount, retailAmount, currency, details, operationType, addDateTime, isDeleted, createdAt, updatedAt}): _subAccount = subAccount, _userName = userName, _moneyAmount = moneyAmount, _wholeSaleAmount = wholeSaleAmount, _retailAmount = retailAmount, _currency = currency, _details = details, _operationType = operationType, _addDateTime = addDateTime, _isDeleted = isDeleted, _createdAt = createdAt, _updatedAt = updatedAt; factory DebtOperation({String? id, SubAccount? subAccount, String? userName, required double moneyAmount, String? wholeSaleAmount, String? retailAmount, String? currency, String? details, OperationType? operationType, amplify_core.TemporalDateTime? addDateTime, int? isDeleted}) { bool equals(Object other) { @OverRide @OverRide @OverRide
} DebtOperation copyWith({SubAccount? subAccount, String? userName, double? moneyAmount, String? wholeSaleAmount, String? retailAmount, String? currency, String? details, OperationType? operationType, amplify_core.TemporalDateTime? addDateTime, int? isDeleted}) { DebtOperation copyWithModelFieldValues({ DebtOperation.fromJson(Map<String, dynamic> json) Map<String, dynamic> toJson() => { Map<String, Object?> toMap() => { static final amplify_core.QueryModelIdentifier MODEL_IDENTIFIER = amplify_core.QueryModelIdentifier();
}); class _DebtOperationModelType extends amplify_core.ModelType { @OverRide @OverRide /**
/** Create an instance of DebtOperationModelIdentifier using [id] the primary key. */ @OverRide @OverRide @OverRide @OverRide @OverRide
} @OverRide |
and here is updated schema One MainAccount has many SubAccountssubAccounts: [SubAccount] @hasmany(indexName: "byMainAccount", fields: ["id"]) type SubAccount @model @auth(rules: [{ allow: owner }]){ Belongs to MainAccount via the mainAccountID fieldmainAccount: MainAccount @belongsTo(fields: ["mainAccountID"]) One SubAccount has many DebtOperationsdebtOperations: [DebtOperation] @hasmany(indexName: "bySubAccount", fields: ["id"]) type DebtOperation @model @auth(rules: [{ allow: owner }]){ Belongs to SubAccount via the subAccountID fieldsubAccount: SubAccount @belongsTo(fields: ["subAccountID"]) enum MessagingWay { enum MessagingType { enum OperationType { |
I didn't realize you were using Flutter. I'm going to go ahead and transfer this to the Flutter team to take a look at. I understand there could be an underlying issue within Swift DataStore, since Flutter DataStore is built on top of it. However, we will start investigating at the Flutter level. |
i realy do appreciate your help |
Hi @Technical-Team-4Dev , no problem, we will take a look and get back to you with an update when we have one |
the new about my issue that can you check if i have any issue in the configuration of amplify or any thing else void main() async { await configureAmplify(); final dbHelper = DatabaseHelper(); setupControllers(database); runApp(MyApp()); Future configureAmplify() async { @OverRide
} Future runInitialChecks(BuildContext context) async {
} |
when i add the data in the subAccount and deptoperation its added successfully while am offline and when i connect to the internet to sync the data its also sync successfully but it disappear from the local datastore after its sync to the cloud while it stay presist in the cloud and disappear from the local data store and this log appears while am adding the data
here i the logs
W/amplify:aws-datastore( 1347): GraphQLResponseException{message=Mutation failed. Failed mutation = PendingMutation{mutatedItem=SerializedModel{id='6cb3f6f8-673b-493a-82cf-377d0974e634', serializedData={userName=, subAccount=SerializedModel{id='3c3bb71f-967f-4621-8913-485587f3b66d', serializedData={id=3c3bb71f-967f-4621-8913-485587f3b66d}, modelName=SubAccount}, createdAt=null, wholeSaleAmount=0, addDateTime=2025-01-14T01:34:04.438737000Z, isDeleted=0, currency=محلي, details=مصاريف, operationType=ALIH, id=6cb3f6f8-673b-493a-82cf-377d0974e634, retailAmount=0, moneyAmount=1240, updatedAt=null}, modelName=DebtOperation}, mutationType=CREATE, mutationId=a78c8718-d217-11ef-9889-9ba63c0f9ccf, predicate=MatchAllQueryPredicate}. AppSync response contained errors = [GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'SubAccount' (/createDebtOperation/subAccount/_lastChangedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_lastChangedAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'Int' within parent 'SubAccount' (/createDebtOperation/subAccount/_version)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_version'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/createdAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='createdAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'ID' within parent 'SubAccount' (/createDebtOperation/subAccount/id)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='id'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'String' within parent 'SubAccount' (/createDebtOperation/subAccount/subAccountName)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='subAccountName'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/updatedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='updatedAt'}]', extensions='null'}], errors=[GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'SubAccount' (/createDebtOperation/subAccount/_lastChangedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_lastChangedAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'Int' within parent 'SubAccount' (/createDebtOperation/subAccount/_version)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='_version'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/createdAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='createdAt'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'ID' within parent 'SubAccount' (/createDebtOperation/subAccount/id)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPath
W/amplify:aws-datastore( 1347): Segment{value='id'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'String' within parent 'SubAccount' (/createDebtOperation/subAccount/subAccountName)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='subAccountName'}]', extensions='null'}, GraphQLResponse.Error{message='Cannot return null for non-nullable type: 'AWSDateTime' within parent 'SubAccount' (/createDebtOperation/subAccount/updatedAt)', locations='null', path='[GraphQLPathSegment{value='createDebtOperation'}, GraphQLPathSegment{value='subAccount'}, GraphQLPathSegment{value='updatedAt'}]', extensions='null'}], recoverySuggestion=See attached list of GraphQLResponse.Error objects.}
W/amplify:aws-datastore( 1347): at com.amplifyframework.datastore.synceng
and here is my shema
type Blog @model @auth(rules: [{ allow: owner }]) {
id: ID!
name: String!
posts: [Post] @hasmany(indexName: "byBlog", fields: ["id"])
}
type Post @model @auth(rules: [{ allow: owner }]) {
id: ID!
title: String!
blogID: ID! @index(name: "byBlog")
blog: Blog @belongsTo(fields: ["blogID"])
comments: [Comment] @hasmany(indexName: "byPost", fields: ["id"])
}
type Comment @model @auth(rules: [{ allow: owner }]) {
id: ID!
postID: ID! @index(name: "byPost")
post: Post @belongsTo(fields: ["postID"])
content: String!
}
type MainAccount @model @auth(rules: [{ allow: owner }]) {
id: ID!
mainAccountName: String! # Non-nullable
userName: String
details: String
icon: String
defaultCurrency: String
isDeleted: Int # Non-nullable (make sure you always provide a value)
One MainAccount has many SubAccounts
subAccounts: [SubAccount] @hasmany(indexName: "byMainAccount", fields: ["id"])
}
type SubAccount @model @auth(rules: [{ allow: owner }]) {
id: ID!
mainAccountID: ID! @index(name: "byMainAccount")
Belongs to MainAccount via the mainAccountID field
mainAccount: MainAccount @belongsTo(fields: ["mainAccountID"])
subAccountName: String! # Non-nullable
defaultCurrency: String
userName: String
image: String
phoneNumber: String
whatsAppNumber: String
address: String
note: String
messagingWay: MessagingWay
messagingType: MessagingType
isDeleted: Int # Non-nullable (make sure you always provide a value)
One SubAccount has many DebtOperations
debtOperations: [DebtOperation] @hasmany(indexName: "bySubAccount", fields: ["id"])
}
type DebtOperation @model @auth(rules: [{ allow: owner }]) {
id: ID!
subAccountID: ID! @index(name: "bySubAccount")
Belongs to SubAccount via the subAccountID field
subAccount: SubAccount @belongsTo(fields: ["subAccountID"])
userName: String
moneyAmount: Float! # Non-nullable
wholeSaleAmount: String
retailAmount: String
currency: String! # Non-nullable
details: String
operationType: OperationType
addDateTime: AWSDateTime! # Non-nullable
isDeleted: Int
}
enum MessagingWay {
sms
whats
}
enum MessagingType {
directly
assurance
never
}
enum OperationType {
ALIH
LAHU
}
The text was updated successfully, but these errors were encountered: