-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
Milestone
Description
I'd like to update Orbit's normalized form to follow the document structure defined by JSON API.
Instead of flattening attributes, relationships, and keys at a single level, I'd like to structure them as follows:
{
type: 'planet',
id: '29e127ea-fb2b-4f7d-9f49-3d502f31d74a',
attributes: {
name: 'Jupiter',
classification: 'gas giant'
},
relationships: {
moons: {
data: [
{type: 'moon', id: '13567508-f2a9-4db4-b895-49273ea42009'},
{type: 'moon', id: '76897508-f2a9-4db4-b895-49273ea42123'}
]
}
}
}
Some details:
type- the record type (i.e. model name)id- the value of the primary key (note that this is Orbit's primary key)attributes- attributes, previously stored at the record rootrelationships- relationships, previously stored as__rel
Advantages
Moving to this normalized form should provide the following benefits:
- The structure allows for much more to be determined in sources semantically without requiring constant references to the schema.
- The structure is extensible and allows for links and meta information.
- It should pave the way for supporting heterogeneous collections and polymorphic relationships.
- The JSONAPISerializer should largely be a noop.
TBD
Secondary keys (e.g. remote IDs) could be stored either:
- in a separate
keysobject for each resource, or - exclusively in a map shared centrally by sources.
If stored in a map, the map's contents will need to be extractable so it can be kept in browser storage.
I'm leaning towards using a separate keys object for simplicity and consistency. Obviously, this element would only be needed for schema that use secondary keys.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels