Skip to main content

getName

Typings:

function getName<U extends AnyParamConstructor<any>>(cl: U, overwriteOptions?: IModelOptions)

Parameters:

NameTypeDescription
cl RequiredUThe Class to get a name from / for
overwriteOptionsIModelOptionsOverwrite select IModelOptions for name generation

getName generates the name of the given Class (cl) with the given OverwriteOptions (overwriteOptions).

Name Generation in typegoose.

Example

class Kitten {}
getName(Kitten); // "Kitten"

@modelOptions({ options: { customName: 'SomeRandomKitten' } })
class Kitten2 {}
getName(Kitten); // "SomeRandomKitten"

@modelOptions({ schemaOptions: { collection: 'RandomKittens' }, options: { automaticName: true } })
class Kitten3 {}
getName(Kitten); // "Kitten3_RandomKittens"