Scope

The scope class is instantiated by the entity manager.

let scope = wetland.getManager();

.attach()

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

scope.attach(entity);

.clear()

Clears the unit of work.

scope.clear();

.detach()

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

scope.detach(entity);

.flush()

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.

scope.flush();

.getConfig()

Gets the wetland configuration.

scope.getConfig();

.getEntities()

Gets all registered entities with the entity manager.

scope.getEntities();

.getEntity();

Gets a single entity with the entity manager.

scope.getEntity('name');

.getReference()

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);

.getRepository()

Returns an entity repository instance for provided entity.

scope.getRepository(entity);

.getStore()

Gets the store for provided entity with wetland.

scope.getStore(entity);

.getUnityOfWork()

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

scope.getUnitOfWork();

.persist()

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]);

.refresh()

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

scope.refresh([entity1, entity2]);

.remove()

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.

scope.remove(entity);

.resolveEntityReference()

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

scope.resolveEntityReference(entity);

results matching ""

    No results matching ""