Page Contents

Home > @loopback/repository > DefaultCrudRepository > entityToData

DefaultCrudRepository.entityToData() method

This function works as a persist hook. It converts an entity from the CRUD operations’ caller to a persistable data that can will be stored in the back-end database.

User can extend DefaultCrudRepository then override this function to execute custom persist hook.

Signature:

protected entityToData<R extends T>(entity: R | DataObject<R>, options?: {}): Promise<legacy.ModelData<legacy.PersistedModel>>;

Parameters

Parameter Type Description
entity R | DataObject<R>  
options {}  

Returns:

Promise<legacy.ModelData<legacy.PersistedModel>>