@loopback/docs
Version:
Documentation for LoopBack 4
38 lines (24 loc) • 1.39 kB
Markdown
---
lang: en
title: 'API docs: repository.defaultcrudrepository.entitytodata'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
editurl: https://github.com/strongloop/loopback-next/tree/master/packages/repository
permalink: /doc/en/lb4/apidocs.repository.defaultcrudrepository.entitytodata.html
---
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@loopback/repository](./repository.md) > [DefaultCrudRepository](./repository.defaultcrudrepository.md) > [entityToData](./repository.defaultcrudrepository.entitytodata.md)
## 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.
<b>Signature:</b>
```typescript
protected entityToData<R extends T>(entity: R | DataObject<R>, options?: {}): Promise<legacy.ModelData<legacy.PersistedModel>>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| entity | <code>R | DataObject<R></code> | The entity passed from CRUD operations' caller. |
| options | <code>{}</code> | |
<b>Returns:</b>
`Promise<legacy.ModelData<legacy.PersistedModel>>`