Global scope for the domain
Obtain an update that captures every mutation made by the app to the domain since the domain was last updated. The update should be immediately written to the m-ld engine. This method also REVERTS the mutations made in the app code. This is because the updates will be very quickly re-applied, having been processed by the m-ld engine, in the next update cycle.
A scope allows a code module such as an extension to avoid seeing some other module's ORM classes when asking for a subject instance. This can be important if the module's subject scope intersects with another module's. Note that in such circumstances it's probably a good idea to use module-specific properties, to avoid interference.
Allows the caller to wait for any active updating state to go out of scope, so that the app is free to mutate ORM subjects without risk of faults. This method can be used to protect any code that is called asynchronously, such as an event handler in a user interface.
Call to obtain an updating state of the domain, to be used to create or load ORM subjects.
a readable m-ld core API state
a procedure that uses the updating state – the given updating state is guaranteed to remain valid until the returned promise settles.
Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.10.0 Source code licensed MIT. Privacy policy
The experimental Object-Resource Mapping (ORM) layer is a set of constructs to support idiomatic use of object-oriented Javascript with the core m-ld API. Instead of programming with reads and writes to the domain graph, you manipulate Javascript objects that reflect the domain.
An ORM domain object is a top-level container for a mutable graph of "subjects" in-memory, where subjects are instances of Javascript classes, and graph edges are straightforward class properties.
Since read operations like traversal of graph edges are asynchronous in m-ld, an ORM domain can be in an "updating" state, in which some edge may not be fully loaded (sometimes called a "fault"). This mode is entered using the updating method. It gives access to an OrmUpdating state, from which graph content can be loaded. An updating state is required to create new subject instances attached to the domain object (also since their properties may need loading).
Mutations of the graph by the app MUST NOT be done in an updating state (a subject property that is not yet loaded could have an unexpected value of
undefined
orempty
; and the app mutation may be overridden by an asynchronous load). An exception to this is setting the initial properties of a new subject. Changes to a subject, or to the whole ORM domain, can be committed to a writeable m-ld state.OrmSubject