Abstract
Internal
Constructs an instance of an Entity.
data needed to construct an instance of an entity viewerContext - the ViewerContext reading this entity id - the ID of this entity databaseFields - all underlying fields for this entity's data selectedFields - selected fields for this entity from TSelectedFields type
This should only be overridden in cases where additional data validation is needed. The params should not be modified when calling super during constructions.
EntityAssociationLoader for this entity
Get a underlying field from this entity's data
the field to get
the value of the field or undefined if not loaded with that field
Static
canCheck whether an entity loaded by a viewer can be deleted by that same viewer.
entity loaded by viewer
query context in which to perform the check
See remarks for canViewerUpdate.
Static
canCheck whether an entity loaded by a viewer can be updated by that same viewer.
entity loaded by viewer
query context in which to perform the check
This may be useful in situations relying upon the thrown privacy policy thrown authorization error is insufficient for the task at hand. When dealing with purely a sequence of mutations it is easy to roll back all mutations given a single authorization error by wrapping them in a single transaction. When certain portions of a mutation cannot be rolled back transactionally (third pary calls, legacy code, etc), using this method can help decide whether the sequence of mutations will fail before attempting them. Note that if any privacy policy rules use a piece of data being updated in the mutations the result of this method and the update mutation itself may differ.
Static
creatorVend mutator for creating a new entity in given query context.
viewer context of creating user
query context in which to perform the create
mutator for creating an entity
Static
deleteDelete an existing entity in given query context.
entity to delete
query context in which to perform the delete
Static
enforceDelete an existing entity in given query context, throwing if deletion is unsuccessful.
entity to delete
query context in which to perform the delete
Static
loaderVend loader for loading an entity in a given query context.
viewer context of loading user
query context in which to perform the load
Static
updaterVend mutator for updating an existing entity in given query context.
entity to update
query context in which to perform the update
mutator for updating existingEntity
Generated using TypeDoc
Entity is a privacy-first data model.
A instance of an entity represents a single "row" of persisted data in a database that a viewer, represented by the corresponding ViewerContext, has permission to read.
Create, read, update, and delete permissions for an entity are declaratively defined using an EntityPrivacyPolicy.
Entites are loaded through an EntityLoader, which is responsible for orchestrating fetching, caching, and authorization of reading "rows".
Entities are mutated and deleted through an EntityMutator, which is responsible for orchestrating database writes, cache invalidation, and authorization of writing "rows".
All concrete entity implementations should extend this class and provide their own EntityCompanionDefinition.