objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
949 stars 116 forks source link

Add support for Embedded Objects #524

Open ibrahim-mubarak opened 1 year ago

ibrahim-mubarak commented 1 year ago

Describe the solution you'd like

@Entity()
class User {
  User(this.id, this.address);

 @Id
  final int id;

 @Embedded()
  final Address? address;
}

class Address {
 final String? streetAddress1;
 final String? streetAddress2
}

Database schema for User then becomes

id
street_address_1
street_address_2

Describe alternatives you've considered

The alternatives are as mentioned in https://github.com/objectbox/objectbox-java/issues/456

Additional context

This request is similar to the features provided in other persistence libraries

greenrobot-team commented 1 year ago

Thanks for your request! For anyone else interested, please thumbs up the first post!

As noted https://github.com/objectbox/objectbox-java/issues/456 is the Java issue about this.

And the current workarounds are to