EntityNameResolver class

Resolves singular and plural forms of entity names. The SDK uses this when deriving collection names for generated data operations, so the plural form an entity resolves to here determines the names you query against.

Register overrides with setCustomPlural when the default English pluralization does not match your domain terminology.

Example

// Ensure the `Person` entity pluralizes to `people`, not `persons`.
EntityNameResolver.setCustomPlural('Person', 'People');
EntityNameResolver.getPlural('Person'); // 'People'

Methods

clearCustomPlurals()

Clears all registered custom plural forms.

getPlural(string)

Gets the plural form of an entity name, honoring any registered custom plural before falling back to standard English pluralization.

getSingular(string)

Gets the singular form of a plural entity name.

isPlural(string)

Determines whether a word is already in plural form.

setCustomPlural(string, string)

Registers a custom plural form for a domain-specific entity name, taking precedence over the default pluralization.

Method Details

clearCustomPlurals()

Clears all registered custom plural forms.

static function clearCustomPlurals()

getPlural(string)

Gets the plural form of an entity name, honoring any registered custom plural before falling back to standard English pluralization.

static function getPlural(entityName: string): string

Parameters

entityName

string

The singular entity name.

Returns

string

The plural form.

getSingular(string)

Gets the singular form of a plural entity name.

static function getSingular(pluralName: string): string

Parameters

pluralName

string

The plural entity name.

Returns

string

The singular form.

isPlural(string)

Determines whether a word is already in plural form.

static function isPlural(word: string): boolean

Parameters

word

string

The word to test.

Returns

boolean

true if the word is plural.

setCustomPlural(string, string)

Registers a custom plural form for a domain-specific entity name, taking precedence over the default pluralization.

static function setCustomPlural(singular: string, plural: string)

Parameters

singular

string

The singular entity name.

plural

string

The plural form to use for that entity.