Skip to content
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

Support embedded objects #662

Closed
lukaspili opened this issue Jun 9, 2022 · 20 comments
Closed

Support embedded objects #662

lukaspili opened this issue Jun 9, 2022 · 20 comments
Assignees

Comments

@lukaspili
Copy link

lukaspili commented Jun 9, 2022

Is it planned at some point? Thanks

@lukaspili lukaspili changed the title Support embedded object Support embedded objects Jun 9, 2022
@nielsenko
Copy link
Contributor

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 nielsenko reopened this Jun 9, 2022
@nielsenko
Copy link
Contributor

Sorry about that. Will close when Embedded objects land.

@lukaspili
Copy link
Author

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

@fiveable-jferg
Copy link

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.

@nirinchev
Copy link
Member

There are no workarounds at this point.

@tanukijs
Copy link

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

@dotjon0
Copy link

dotjon0 commented Aug 15, 2022

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

@nielsenko
Copy link
Contributor

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.)

@dotjon0
Copy link

dotjon0 commented Aug 16, 2022

Thanks @nielsenko appreciate and appreciate your update!

@nirinchev
Copy link
Member

This is done and will be released shortly

@ffelicioautodoc
Copy link

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!

@nielsenko
Copy link
Contributor

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.

@dotjon0
Copy link

dotjon0 commented Oct 31, 2022

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!

@ffelicioautodoc
Copy link

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.

@nielsenko
Copy link
Contributor

@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.

@ffelicioautodoc
Copy link

@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.

@dotjon0
Copy link

dotjon0 commented Oct 31, 2022

@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.

@dotjon0
Copy link

dotjon0 commented Oct 31, 2022

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

@ffelicioautodoc
Copy link

@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.

@nielsenko
Copy link
Contributor

@dotjon0 let us continue in #1001 👍

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants