-
Notifications
You must be signed in to change notification settings - Fork 585
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
Embedded Objects #2676
Comments
The schema can be extended to look like:
The new schema attribute Creating a nested object:
Alternatively, the object can be created in two steps:
|
I would suggest the shorter |
Also - I think the two step approach of first creating an embedded object and then embedding it should not be supported, as the scope reads:
If it was not the case, what would happen to the embedded object if it never gets embedded? |
Another suggestion could be to allow defining the schema of an embedded object, in the definition of the parent object: const Person = {
name: 'Person',
primaryKey: 'id',
properties: {
id: 'int',
firstName: 'string',
lastName: 'string',
robots: {
type: 'list',
objectType: {
name: 'Robot',
properties: {
name: 'string',
builder: 'string'
}
}
}
}
}; The user don't need to specify that the "Robot" is embedded as this is the only case where "objectType" is an object instead of a string. A simple (not a list) link to an embedded object could be represented as: const Person = {
name: 'Person',
primaryKey: 'id',
properties: {
id: 'int',
firstName: 'string',
lastName: 'string',
robot: {
name: 'Robot',
properties: {
name: 'string',
builder: 'string'
}
}
}
}; We can identify the embedded object definition as its now missing a |
Keep in mind that embedded Object is allowed to be embedded in multiple places (e.g the type of the parent might not be fixed) |
The suggestion by @kraenhansen above is very natural for a JS developer - but is a restriction compared to my initial suggestion. Therefore I believe we should support both. |
As @kneth's suggestion is the only one that supports the full scope of the feature, I think we should start with that and keep my suggestion as an idea for future improvements. |
Can we move the discussion on the design doc. Thus having the final decision there and iterating over it at once |
I think this should/will not be allowed in the other SDKs let marvin = realm.create('Robot', {
name: 'Marvin',
builder: 'Sirius Cybernetics Corporation'
}
); |
UPDATE on the above: there is no consensus on that |
Sure thing - I think @kneth's intention on his initial comment was just to kick off a discussion before we started adding stuff to the doc. I see no reason that we cannot more this into the doc.
I agree, thats what I ment by #2676 (comment). |
I having to trouble to embed data , tried above @kraenhansen approach but didn't work,
This is My Schema :
|
See RPM-72 for details.
PR: #2724
The text was updated successfully, but these errors were encountered: