AdminEntity API
AdminEntity options
All options are defined on the AdminEntity class:
// user.admin.ts
import { AdminEntity } from 'nestjs-admin'
import { User } from './user.entity'
export class UserAdmin extends AdminEntity {
entity = User
listDisplay = ['firstname', 'lastname']
}
AdminEntity.fields
Configures which fields of the entity will be displayed (and therefore editable) in the create and update forms.
fields = ['firstName', 'lastName', 'createdDate', 'gender']
- If you don't set
fields
, the create and update forms will display all properties of the entity
AdminEntity.listDisplay
Configures which fields of the entity will be displayed on the list page.
listDisplay = ['id', 'firstname', 'lastname', 'email']
If you don't set
listDisplay
, the list page will display a single column containing the primary key of the entity, or thetoString()
representation of the entity if defined.listDisplay
values cannot refer toManyToOne
,OneToMany
orManyToMany
fields.
AdminEntity.searchFields
Configures whether the search box will be displayed on the list page, and which fields of the entity will be searched.
searchFields = ['firstName', 'lastName', 'createdDate', 'gender']
- If you don't set
searchFields
, the search box will not be displayed on the list page. - If you search for
john
, the entity instances will be displayed ifjohn
appears in any of the configured fields. - If you search for
john smith
, an entity instance will be displayed ifjohn
appears in any of the configured fields AND ifsmith
appears in any of the configured fields.