Closed badayumut closed 2 weeks ago
From what I can see the constructors of the classes you have given do not have parameters for the relation fields:
Book({
required this.content, // no parameter for author
});
Person({
required this.name, // no parameter for books
});
In any case, I would strongly recommend to use a different model for the database and the JSON serializer and map between them. It would avoid this issue and also make any future changes easier to handle.
Let me know if this resolves your issue!
I was about to update the issue with that the generated example_model.g.dart did not have the rel convertion methods. Anyway I couldn't make it work this way. So i implemented a custom map for to-from methods. I think it's the best way to it with more control. Thanks!
Is there an existing issue?
Build info
flutter --version
ordart --version
]Steps to reproduce
I'm working on exporting the model to json and retrieving it, and I reviewed the example here. I tried to implement it to my own model in the same way. Simple parameters (String, int) in the model are saved in json, but I cannot extract relations. Is there something I missed? I'm trying to transfer the model as it is with relations and get it back. https://github.com/objectbox/objectbox-dart/blob/main/generator/integration-tests/part-partof/lib/json.dart
Expected behavior
should be able to access relations after created from json
Actual behavior
relations missing after json serialization
Code
Logs, stack traces
TODO Add relevant logs, a stack trace or crash report.
Logs
```console [Paste your logs here] ```