NgRx Auto-Entity
Primary version
Primary version
  • NgRx Auto-Entity
  • Getting Started
    • Installation
    • Quick Start
    • Use your State!
      • Enhancing your Facade
      • Simplify your Component
    • From Scratch
      • App Interfaces
      • App Reducer
      • App State Module
      • Entity Model
      • Entity State
      • Update App State
      • Entity Service
      • Update App Module
  • Advanced Topics
    • Advanced Usage
      • Paradigm Changes
        • Models
        • Services
        • Service Providers
      • Taking Control
        • Integrating Custom Effects
      • Building Your Entities
        • Entity Names
        • Sort Comparers
        • Data Transforms
      • Building Your Entity States
        • The buildState() function
        • The buildFeatureState() function
        • The IEntityState Interface
        • The Selector Map
      • Generic Actions
        • Actions Now
        • Reusable Generic Actions
        • Custom Criteria
        • Loading Actions
          • Loading Entities
          • Loading Pages
          • Loading Ranges
        • Optional Loading
        • CURD Actions
        • Utility Actions
      • Correlation
      • Common Selectors
        • Exporting Selectors
      • Extra Selectors
      • Custom Selectors
        • Adding to Facades
        • Using Custom Selectors
      • Custom Effects
        • Composing Actions
        • Workflows
    • Leveraging Facades
      • Preparing Facades
      • The Interface: Selections
        • Using Facade Selections
        • Simplifying Further
      • The Interface: Activities
        • Using Facade Activities
      • So Little Code!
    • Utility Functions
      • Prototyping your Entities
        • Entity Making Performance
      • Entity Name Utilities
      • Entity Key Utilities
      • Entity Comparers
  • Examples
    • Sample Application
      • App Module
      • State
      • Models
      • Services
      • Facades
      • Container Components
      • Presentation Components
      • Modal Component
  • Documentation
    • Reference
  • Extras
    • Github Link
Powered by GitBook
On this page
Export as PDF
  1. Advanced Topics
  2. Advanced Usage
  3. Building Your Entities

Entity Names

PreviousBuilding Your EntitiesNextSort Comparers

Last updated 4 years ago

In addition to the modelName, the @Entity decorator supports other names. These include the pluralName which can be useful for dynamically describing entities in plurality in log messages, messages displayed in the ui, etc. Additionally a uriName may be specified that can be used when building API endpoint urls in your entity services.

Some examples of using the @Entity decorator to name your entities:

import { Entity } from '@briebug/ngrx-auto-entity';

@Entity('Customer')
@Entity({ modelName: 'Customer' })
@Entity('Customer', { pluralName: 'Customers' })
@Entity({ 
  modelName: 'Customer',
  pluralName: 'Customers',
  uriName: 'customers'
})
export class Customer {}
import { Entity } from '@briebug/ngrx-auto-entity';

@Entity({ modelName: 'LineItem' })
@Entity('LineItem', { pluralName: 'LineItems' })
@Entity({ 
  modelName: 'LineItem',
  pluralName: 'LineItems',
  uriName: 'line-item'
})
export class LineItem {}

Auto-entity provides a number of utility functions for retrieving the various names of entities. Refer to the documentation for more information.

Note that each entity class may only be decorated by the @Entity decorator once! The above multiple uses is only for example's sake.

Utility Functions