You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, when creating a relation in the model definition using oneOf/manyOf functions, what you effectively create is a draft for the future relation. Until the relation has access to the entire dictionary (map of models), it cannot know what primaryKey the referenced model has.
This implies that any defined relation must be "evolved".
Unapparent how to re-define relational properties
When updating entities via update/updateMany, you can also update relational properties (support added in #126). However, the implementation for that update is unapparent and seems unsemantic to the Relation class. If forces the updateEntity function to require access to the model definition and the database in order to create a new relational property (the getter it defines on the entity queries the database for the given referenced model's primary key and other data).
Manual retrieval of the referenced model primary key
The relation definition (the one you provide in the model) doesn't know about the referenced model's primary key.
What's worse, is that in the case of manyOf relations, the referenced entities are stored in a list. So to get an idea of the primary key of the referenced model you have to get the first entity from the referenced list:
// In "manyOf" relation the previous value will be an array of entities.
// Get the first entity and its primary key property name.
constprimaryKey=[].concat(prevValue)[0][
InternalEntityProperty.primaryKey
]
Primary key property name cannot be changed on runtime, it's a fixed string. It'd make much more sense to resolve that primary key name when relation definition becomes a relation (is produced). That way there'd be no need to look up primary keys anymore.
The text was updated successfully, but these errors were encountered:
Issues
Relational properties are all over the place
First, when creating a relation in the model definition using
oneOf
/manyOf
functions, what you effectively create is a draft for the future relation. Until the relation has access to the entire dictionary (map of models), it cannot know whatprimaryKey
the referenced model has.This implies that any defined relation must be "evolved".
Unapparent how to re-define relational properties
When updating entities via
update
/updateMany
, you can also update relational properties (support added in #126). However, the implementation for that update is unapparent and seems unsemantic to theRelation
class. If forces theupdateEntity
function to require access to the model definition and the database in order to create a new relational property (the getter it defines on the entity queries the database for the given referenced model's primary key and other data).Manual retrieval of the referenced model primary key
The relation definition (the one you provide in the model) doesn't know about the referenced model's primary key.
data/src/model/defineRelationalProperties.ts
Line 63 in 9f88f0d
What's worse, is that in the case of
manyOf
relations, the referenced entities are stored in a list. So to get an idea of the primary key of the referenced model you have to get the first entity from the referenced list:data/src/model/updateEntity.ts
Lines 67 to 71 in 9f88f0d
Primary key property name cannot be changed on runtime, it's a fixed string. It'd make much more sense to resolve that primary key name when relation definition becomes a relation (is produced). That way there'd be no need to look up primary keys anymore.
The text was updated successfully, but these errors were encountered: