The scope class is instantiated by the entity manager.

let scope = wetland.getManager();


This method is used to proxy an entity with the entity proxy.



Clears the unit of work.



Removes proxy and clear this entity from the unit of work.



This method is responsible for persisting the unit of work. This means calculating changes to make, as well as the order to do so. One of the things involved in this is making the distinction between stores.

// Skip cleaning (state) of entities. Saves on performance.
// Only use if you're done with the scope.
const skipClean = true;

// Skips the lifecycle hooks on the entities. Useful in rare situations.
const skipLifecycleHooks = true;

// Some options to override the defaults for this specific flush.
// Refresh is responsible for re-fetching the entity's data from the database.
const config = { refreshCreated: true, refreshUpdated: true };

// Aaaand flush!
scope.flush(skipClean, skipLifecycleHooks, config);


Gets the wetland configuration.



Gets all registered entities with the entity manager.



Gets a single entity with the entity manager.



Gets a reference to a persisted row without actually loading it from the database, or returns a row found in the IdentityMap (if fetched earlier in the scope). Besides giving it the entity, you also need to specify the primary key value of the targeted row.

scope.getReference(entity, 1);


Returns an entity repository instance for provided entity.



Gets the store for provided entity with wetland.



Returns an instance of unit of work. The methods of the unit of work are listed and described here.



Mark provided entity as new with the unit of work. This method returns .registerNew() from the unit of work to register new entities that will be persisted when .flush() is called.

scope.persist([entity1, entity2]);


This method refreshes provided entities, syncing with the database. Entities must be passed as an array.

scope.refresh([entity1, entity2]);


Marks an entity as deleted with the unit of work. This method returns .registerDeleted() from the unit of work to register the provided entity as deleted. While it is registered as deleted, the entity will be deleted from the database when .flush() is called.



Resolve provided value to an entity reference. The argument can be a name, a constructor or the entity itself.


results matching ""

    No results matching ""