Ent API: load*() by ID
There is a basic primitive used very frequently: having some Ent ID, load this Ent into memory.
There are several versions of load*
static methods on each Ent class:
Ent.loadX(vc, id): Ent
Loads an Ent by ID.
Throws EntNotFoundError
if there is no such Ent in the database, or EntNotReadableError
if the VC has no permissions to read it.
Ent.loadNullable(vc, id): Ent | null
loads an Ent by ID if it exists in the database, otherwise returns null.
If an Ent with such ID exists, but the VC doesn't have permissions to access it, the call will throw EntNotReadableError
.
Ent.loadIfReadableNullable(vc, id): Ent | null
This is a special method designed to return null
in two cases: when an Ent with the specified ID does not exist, or when the user lacks the necessary permissions to read it. Basically, it never throws.
Permissions are enforced by the privacyLoad
rules of the Ent, which were briefly introduced earlier and will be covered in more detail later.
There is intentionally no method which loads multiple Ents at once taking an array of IDs. Read further on, why.
Last updated
Was this helpful?