realm-dart icon indicating copy to clipboard operation
realm-dart copied to clipboard

Support embedded objects

Open lukaspili opened this issue 2 years ago • 9 comments

Is it planned at some point? Thanks

lukaspili avatar Jun 09 '22 01:06 lukaspili

Hi Lukasz

Great to see you here.

Yes, we plan to support embedded objects. There are a number of major and minor features we are still missing.

  • Embedded objects,
  • Mixed,
  • Sets,
  • Maps,
  • Upserts,
  • Better client-reset handling,
  • Async writes, and
  • Asymmetric sync

comes to mind.

In general the Flutter / Dart SDK will support all features, supported by the other SDKs, unless the feature is considered deprecated.

However, we cannot give exact timelines for when each feature will land..

Br, Kasper

nielsenko avatar Jun 09 '22 06:06 nielsenko

Sorry about that. Will close when Embedded objects land.

nielsenko avatar Jun 09 '22 06:06 nielsenko

Thanks for the detailed answer. Understandable for not having a specific timeline. Looking forward to the next updates then!

lukaspili avatar Jun 10 '22 18:06 lukaspili

Is there any sort of documented workaround for this gap at the moment? It basically means the SDK is not usable for my database schema at the moment.

fiveable-jferg avatar Jun 25 '22 16:06 fiveable-jferg

There are no workarounds at this point.

nirinchev avatar Jun 25 '22 18:06 nirinchev

I'm also waiting for "Embedded objects" to switch to Realm!

tanukijs avatar Jun 27 '22 09:06 tanukijs

Afternoon, just wondering if there are any updates on embedded objects / arrays? Hope you are all well

dotjon0 avatar Aug 15 '22 11:08 dotjon0

As you know I'm really not allowed to give ETAs. I can say that we intend to make more incremental releases than we have in the past, and that embedded objects are high on our agenda.

In the meantime, consider if it is possible to either use full-blown realm objects, or serialise in-and-out of a String (fx.)

nielsenko avatar Aug 15 '22 19:08 nielsenko

Thanks @nielsenko appreciate and appreciate your update!

dotjon0 avatar Aug 16 '22 11:08 dotjon0

This is done and will be released shortly

nirinchev avatar Oct 21 '22 14:10 nirinchev

Hello everybody!

First, thanks for updating the lib with the specification of enbedded objects.

I would like your help regarding the use of the resource.

I'm trying to synchronize the schema, but it's generating an error when doing the process.

I have 2 separate classes to handle the data and the relationship with the embedded object, but when building the app, an error message is returned.

@RealmModel()
@MapTo('person')
class _Person {
  late String name;

  @MapTo('address')
  _Address? personAddress;
}

// The generated `Address` class will be an embedded object.
@RealmModel(ObjectType.embeddedObject)
class _Address {
  late String street;
  late String city;
}

Part of the generated file:

// ...another properties
SchemaProperty('address', RealmPropertyType.object, mapTo: 'address', optional: true, linkTarget: 'Address'),

When I start the application, the message below is displayed:

RealmException (RealmException: Error opening realm at path /data/data/br.com.project/files/mongodb-realm/project/635ff39dfb368ea22639a5cb/default.realm. Error code: 18 . Message: Schema validation failed due to the following errors:
- Property 'person.address' of type 'object' has unknown object type 'Address'

I've run on several emulators (Ios and Android), devices (Asus, Iphone 12, Xiaomi), but in all of them the error is persisting.

Is there a process I'm missing?

Thanks!

ffelicioautodoc avatar Oct 31 '22 16:10 ffelicioautodoc

Hi @ffelicioautodoc

How does your code look for creating the configuration and opening the realm?

BTW: It is typically better to open a new issue.

nielsenko avatar Oct 31 '22 16:10 nielsenko

Just saw this was closed but cant see a new issue raised yet so thought we would pop here:

@nielsenko we have also seen similar behaviour - to get around this we had to included the 'embedded object' inside Configuration <SchemaObject>[. We assumed 'embedded objects' would not have to be included within the Configuration <SchemaObject>[ - in our case this approach would lead to 100s of additional SchemaObject (i.e. 'embedded objects') within the Configuration <SchemaObject>[ which is not ideal from a readability or maintainability perspective. Meaning to raise this, so good @ffelicioautodoc raised, thanks!

dotjon0 avatar Oct 31 '22 16:10 dotjon0

Oi@ffelicioautodoc

Como seu código procura criar a configuração e abrir o realm?

BTW: Normalmente é melhor abrir um novo problema.

So I will open a new issue as you suggested.

Thank you for your help.

ffelicioautodoc avatar Oct 31 '22 16:10 ffelicioautodoc

@dotjon0 and @ffelicioautodoc

That is correct, you need to add the Address.schema to the schemaObjects argument when creating the configuration. This is what I suspect you are missing @ffelicioautodoc.

@dotjon0 I see your point, but that is a current requirement. Embedded objects are not that different from top level objects internally in realm-core.

But we should be able help you add the transitive closure of all dependencies.

nielsenko avatar Oct 31 '22 16:10 nielsenko

@dotjon0 and @ffelicioautodoc

That is correct, you need to add the Address.schema to the schemaObjects argument when creating the configuration. This is what I suspect you are missing @ffelicioautodoc.

@dotjon0 I see your point, but that is a current requirement. Embedded objects are not that different from top level objects internally in realm-core.

But we should be able help you add the transitive closure of all dependencies.

So I will do as you suggested.

At creation I was not including the Address schema in the settings. I just left them like this:

final config = Configuration.flexibleSync(
  user,
  [
    Person.schema,
  ],
);

Thanks a lot for the help @nielsenko and @dotjon0. You guys saved a life here.

ffelicioautodoc avatar Oct 31 '22 16:10 ffelicioautodoc

@nirinchev thanks for confirmation - ive raised a feature request https://github.com/realm/realm-dart/issues/1001 to support not having to place 'embedded objects' within the Configuration<SchemaObject>.

@ffelicioautodoc pleasure.

Have a good evening both.

dotjon0 avatar Oct 31 '22 16:10 dotjon0

@nielsenko what do you mean by "But we should be able help you add the transitive closure of all dependencies." ?

dotjon0 avatar Oct 31 '22 16:10 dotjon0

@nirinchev thanks for confirmation - ive raised a feature request #1001 to support not having to place 'embedded objects' within the Configuration.

@ffelicioautodoc pleasure.

Have a good evening both.

Thanks for the mention @dotjon0

Good evening and thanks again for your help.

ffelicioautodoc avatar Oct 31 '22 17:10 ffelicioautodoc

@dotjon0 let us continue in #1001 👍

nielsenko avatar Oct 31 '22 17:10 nielsenko