flutterdata / flutter_data

Seamlessly manage persistent data in your Flutter apps
MIT License
410 stars 31 forks source link

HasMany not being serialized with Save Request #173

Closed oarshad closed 2 years ago

oarshad commented 2 years ago

Trying to write a nested model with HasMany mapping, however, when saving the object, the nested relationship entities are being sent as an empty array.

final t1 = Task(title: 'do 1');
final t2 = Task(title: 'do 2');
final user = User(name: 'Frank', tasks: HasMany({t1, t2}));

ref.users.save(user); // This sends tasks as empty [];
frank06 commented 2 years ago

What adapters are you using? What Flutter Data version?

Tests are passing in that scenario: https://github.com/flutterdata/flutter_data/blob/master/test/repository/remote_adapter_serialization_test.dart#L24

https://github.com/flutterdata/flutter_data/blob/master/test/repository/remote_adapter_serialization_test.dart#L59-L65

frank06 commented 2 years ago

The issue is that your tasks have no IDs.