-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Let's consider having an entity called User and an entity called UserSettings. Each user has exactly one user settings object. A UserSettings object has a reference id to its user object in a field called userId.
The goal is to get more clever invalidations. Right now we can only say, that a change to a User should invalidate all UserSettings objects we have in our cache. By defining an association between these two entities, we could automatically do more fine grained invalidations. Only when the user with id x changes, the settings object with a reference id of x is invalidated.
The configuration for this could live in the regular config object, passed to build:
{
user: {
api: userApi
},
userSettings: {
api: userSettingsApi,
associatedEntity: 'user',
associationIdFrom: (userSettings) => userSettings.userId
}
}
Alternatively several such associations could be defined:
{
user: {
api: userApi
},
userSettings: {
api: userSettingsApi,
associatedEntities: [{ entity: 'user', referenceIdFrom: (userSettings) => userSettings.userId }]
}
}
Does this sound like a legitimate and valuable use case?