Options
All
  • Public
  • Public/Protected
  • All
Menu

@pebula/goosetyped

Index

Type aliases

ClassDecoratorOf

ClassDecoratorOf<TInstance, TStatic>: (target: Type<TInstance, TStatic>) => any

Type parameters

  • TInstance

  • TStatic

Type declaration

    • (target: Type<TInstance, TStatic>): any
    • Parameters

      • target: Type<TInstance, TStatic>

      Returns any

ColumnRequired

ColumnRequired: boolean | string | (() => boolean) | [() => boolean, string]

GtIndexSortOrder

GtIndexSortOrder: "asc" | "desc"

GtSchemaTypeMetadataArgs

MethodDecoratorOf

MethodDecoratorOf<TArgs, TReturn>: <Z, K>(target: Z, key: K, descriptor: TypedPropertyDescriptor<(...args: TArgs) => TReturn>) => TypedPropertyDescriptor<(...args: TArgs) => TReturn> | void

Type parameters

  • TArgs: [any] | [any, any] | [any, any, any] | [any, any, any, any] | [any, any, any, any, any] | [any, any, any, any, any, any] | [any, any, any, any, any, any, any]

  • TReturn

Type declaration

    • <Z, K>(target: Z, key: K, descriptor: TypedPropertyDescriptor<(...args: TArgs) => TReturn>): TypedPropertyDescriptor<(...args: TArgs) => TReturn> | void
    • Type parameters

      • Z: Partial<Record<K, (...args: TArgs) => TReturn>>

      • K: string

      Parameters

      • target: Z
      • key: K
      • descriptor: TypedPropertyDescriptor<(...args: TArgs) => TReturn>

      Returns TypedPropertyDescriptor<(...args: TArgs) => TReturn> | void

PropertyDecoratorOf

PropertyDecoratorOf<T>: <Z, K>(target: Z, key: K) => void

Type parameters

  • T

Type declaration

    • <Z, K>(target: Z, key: K): void
    • Type parameters

      • Z: Partial<Record<K, T>>

      • K: string

      Parameters

      • target: Z
      • key: K

      Returns void

StaticMethodDecoratorOf

StaticMethodDecoratorOf<TArgs, TReturn>: <Z, K>(target: Z, key: K, descriptor: TypedPropertyDescriptor<(...args: TArgs) => TReturn>) => TypedPropertyDescriptor<(...args: TArgs) => TReturn> | void

Type parameters

  • TArgs: [any] | [any, any] | [any, any, any] | [any, any, any, any] | [any, any, any, any, any] | [any, any, any, any, any, any] | [any, any, any, any, any, any, any]

  • TReturn

Type declaration

    • <Z, K>(target: Z, key: K, descriptor: TypedPropertyDescriptor<(...args: TArgs) => TReturn>): TypedPropertyDescriptor<(...args: TArgs) => TReturn> | void
    • Type parameters

      • Z: Function & Partial<Record<K, (...args: TArgs) => TReturn>>

      • K: string

      Parameters

      • target: Z
      • key: K
      • descriptor: TypedPropertyDescriptor<(...args: TArgs) => TReturn>

      Returns TypedPropertyDescriptor<(...args: TArgs) => TReturn> | void

StripDoColumns

StripDoColumns<T, TExcept>: Pick<T, SetDifference<NonFunctionKeys<T>, Exclude<keyof Document_2, TExcept>>>

A type helper that strips away all members of the mongoose Document instance from the type as well as all methods.

example
export class Message extends GtModel() {
 id: string;
 text: string;
 myMethod(): void { }
}

const msg = new Message(); // Not the msg instance has a lot of members from the Document type (The instance of Model)
const m: StripDoColumns<Message>; // now m has only "text" but not "id"

// Since "id" also exists in Document, to include it we need to exclude it from the strip.
const m: StripDoColumns<Message, 'id'>; // now m has "id" & "text"
```

Type parameters

  • T: Document_2

  • TExcept: keyof Document_2

StripDoc

StripDoc<T, TExcept>: Subtract<T, Omit<Document_2, TExcept>>

A type helper that strips away all members of the mongoose Document instance from the type

example
export class Message extends GtModel() {
 id: string;
 text: string;
 myMethod(): void { }
}

const msg = new Message(); // Not the msg instance has a lot of members from the Document type (The instance of Model)
const m: StripDoc<Message>; // now m has only "myMethod" & "text" but not "id"

// Since "id" also exists in Document, to include it we need to exclude it from the strip.
const m: StripDoc<Message, 'id'>; // now m has "id", "myMethod" & "text"
```

Type parameters

  • T: Document_2

  • TExcept: keyof Document_2

Type

Type<TInstance, TStatic>: Ctor<TInstance> & TStatic

Type parameters

  • TInstance

  • TStatic

Validator

Validator: RegExp | ValidatorFn | ValidatorOpts | ValidatorOpts[]

ValidatorFn

ValidatorFn<T>: (value: T) => boolean | Promise<boolean>

Type parameters

  • T

Type declaration

    • (value: T): boolean | Promise<boolean>
    • Parameters

      • value: T

      Returns boolean | Promise<boolean>

Variables

Const GT_DOCUMENT

GT_DOCUMENT: keyof symbol

Const GT_SUB_DOCUMENT

GT_SUB_DOCUMENT: keyof symbol

Functions

GtColumn

GtDeleteOneHook

  • Parameters

    • stage: "pre" | "post"

    Returns MethodDecoratorOf<never, any>

GtDiscriminator

GtDocument

GtIndex

  • Parameters

    Returns PropertyDecorator

  • Parameters

    Returns ClassDecorator

GtInitHook

  • Parameters

    • stage: "pre" | "post"

    Returns MethodDecoratorOf<never, void>

GtInsertManyHook

  • Parameters

    • stage: "post"

    Returns StaticMethodDecoratorOf<[any[]], any>

  • Parameters

    • stage: "pre"

    Returns StaticMethodDecoratorOf<never, any>

GtLocalProp

  • GtLocalProp(): PropertyDecorator
  • Returns PropertyDecorator

GtMethod

  • GtMethod(): MethodDecorator
  • Returns MethodDecorator

GtModel

  • GtModel(): Ctor<Document_2> & Model
  • GtModel<T1, C1>(m1: C1 & Ctor<T1>): Ctor<Document_2 & T1> & Model & C1
  • GtModel<T1, C1, T2, C2>(m1: C1 & Ctor<T1>, m2: C2 & Ctor<T2>): Ctor<Document_2 & T1 & T2> & Model & C1 & C2
  • GtModel<T1, C1, T2, C2, T3, C3>(m1: C1 & Ctor<T1>, m2: C2 & Ctor<T2>, m3: C3 & Ctor<T3>): Ctor<Document_2 & T1 & T2 & T3> & Model & C1 & C2 & C3
  • GtModel<T1, C1, T2, C2, T3, C3, T4, C4>(m1: C1 & Ctor<T1>, m2: C2 & Ctor<T2>, m3: C3 & Ctor<T3>, m4: C4 & Ctor<T4>): Ctor<Document_2 & T1 & T2 & T3 & T4> & Model & C1 & C2 & C3 & C4
  • GtModel<T1, C1, T2, C2, T3, C3, T4, C4, T5, C5>(m1: C1 & Ctor<T1>, m2: C2 & Ctor<T2>, m3: C3 & Ctor<T3>, m4: C4 & Ctor<T4>, m5: C5 & Ctor<T5>): Ctor<Document_2 & T1 & T2 & T3 & T4 & T5> & Model & C1 & C2 & C3 & C4 & C5
  • Returns Ctor<Document_2> & Model

  • Type parameters

    • T1

    • C1

    Parameters

    Returns Ctor<Document_2 & T1> & Model & C1

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    Parameters

    Returns Ctor<Document_2 & T1 & T2> & Model & C1 & C2

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    • T3

    • C3

    Parameters

    Returns Ctor<Document_2 & T1 & T2 & T3> & Model & C1 & C2 & C3

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    • T3

    • C3

    • T4

    • C4

    Parameters

    Returns Ctor<Document_2 & T1 & T2 & T3 & T4> & Model & C1 & C2 & C3 & C4

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    • T3

    • C3

    • T4

    • C4

    • T5

    • C5

    Parameters

    Returns Ctor<Document_2 & T1 & T2 & T3 & T4 & T5> & Model & C1 & C2 & C3 & C4 & C5

GtPlugin

  • Parameters

    Returns ClassDecorator

GtQuery

  • GtQuery<Q1>(QH: Ctor<Q1>): <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1>
  • GtQuery<Q1, Q2>(Q1: Ctor<Q1>, Q2: Ctor<Q2>): <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1 & Q2>
  • GtQuery<Q1, Q2, Q3>(Q1: Ctor<Q1>, Q2: Ctor<Q2>, Q3: Ctor<Q3>): <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3>
  • GtQuery<Q1, Q2, Q3, Q4>(Q1: Ctor<Q1>, Q2: Ctor<Q2>, Q3: Ctor<Q3>, Q4: Ctor<Q4>): <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3 & Q4>
  • Type parameters

    • Q1

    Parameters

    Returns <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1>

      • Type parameters

        • T

        • C

        Parameters

        Returns Ctor<Document_2 & T> & C & Model<Q1>

  • Type parameters

    • Q1

    • Q2

    Parameters

    Returns <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1 & Q2>

      • <T, C>(Cls: Ctor<Document_2 & T> & Model & C): Ctor<Document_2 & T> & C & Model<Q1 & Q2>
      • Type parameters

        • T

        • C

        Parameters

        Returns Ctor<Document_2 & T> & C & Model<Q1 & Q2>

  • Type parameters

    • Q1

    • Q2

    • Q3

    Parameters

    Returns <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3>

      • <T, C>(Cls: Ctor<Document_2 & T> & Model & C): Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3>
      • Type parameters

        • T

        • C

        Parameters

        Returns Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3>

  • Type parameters

    • Q1

    • Q2

    • Q3

    • Q4

    Parameters

    Returns <T, C>(Cls: Ctor<Document_2 & T> & Model & C) => Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3 & Q4>

      • <T, C>(Cls: Ctor<Document_2 & T> & Model & C): Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3 & Q4>
      • Type parameters

        • T

        • C

        Parameters

        Returns Ctor<Document_2 & T> & C & Model<Q1 & Q2 & Q3 & Q4>

GtRemoveHook

  • Parameters

    • stage: "pre" | "post"

    Returns MethodDecoratorOf<never, any>

GtResource

  • Returns Ctor<SubDocument> & Resource

  • Type parameters

    • T1

    • C1

    Parameters

    Returns Ctor<SubDocument & T1> & Resource & C1

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    Parameters

    Returns Ctor<SubDocument & T1 & T2> & Resource & C1 & C2

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    • T3

    • C3

    Parameters

    Returns Ctor<SubDocument & T1 & T2 & T3> & Resource & C1 & C2 & C3

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    • T3

    • C3

    • T4

    • C4

    Parameters

    Returns Ctor<SubDocument & T1 & T2 & T3 & T4> & Resource & C1 & C2 & C3 & C4

  • Type parameters

    • T1

    • C1

    • T2

    • C2

    • T3

    • C3

    • T4

    • C4

    • T5

    • C5

    Parameters

    Returns Ctor<SubDocument & T1 & T2 & T3 & T4 & T5> & Resource & C1 & C2 & C3 & C4 & C5

GtSaveHook

  • Parameters

    • stage: "pre" | "post"

    Returns MethodDecoratorOf<never, any>

GtSchemaType

  • Parameters

    Returns ClassDecorator

GtSkipVersioning

  • GtSkipVersioning(): PropertyDecorator
  • Returns PropertyDecorator

GtSubDocument

GtTimestampCreated

  • Type parameters

    • T

    Returns PropertyDecoratorOf<T>

GtTimestampUpdated

  • Type parameters

    • T

    Returns PropertyDecoratorOf<T>

GtToJSON

  • GtToJSON(config?: Omit<DocumentToObjectOptions, "transform">): MethodDecoratorOf<[any, any]>
  • A decorator for toJSON with a prototype bound implementation for the transform function.

    Note that it recommended to avoid using a transform function (through schema options) or a transform method through this decorator and instead apply a transformation by overriding the toJSON. Call the super method and apply changed to the returned value, this is much better then using an out of context transformer.

    link

    https://mongoosejs.com/docs/4.x/docs/guide.html#toJSON

    Parameters

    • Optional config: Omit<DocumentToObjectOptions, "transform">

    Returns MethodDecoratorOf<[any, any]>

GtToObject

  • GtToObject(config?: Omit<DocumentToObjectOptions, "transform">): MethodDecoratorOf<[any, any]>
  • A decorator for toObject with a prototype bound implementation for the transform function.

    Note that it recommended to avoid using a transform function (through schema options) or a transform method through this decorator and instead apply a transformation by overriding the toObject. Call the super method and apply changed to the returned value, this is much better then using an out of context transformer.

    link

    https://mongoosejs.com/docs/4.x/docs/guide.html#toObject

    Parameters

    • Optional config: Omit<DocumentToObjectOptions, "transform">

    Returns MethodDecoratorOf<[any, any]>

GtUpdateOneHook

  • Parameters

    • stage: "pre" | "post"

    Returns MethodDecoratorOf<never, any>

GtValidateHook

  • Parameters

    • stage: "pre" | "post"

    Returns MethodDecoratorOf<never, any>

GtVersionKey

  • Type parameters

    • T

    Returns PropertyDecoratorOf<T>

addConnection

  • addConnection(connectionId: string, connectionFactory: () => Connection | Promise<Connection>, connectOptions?: GtConnectOptions): Promise<unknown>
  • Registers a connection with GooseTyped to be used to compile Models registered under the same connection Id.

    Parameters

    • connectionId: string

      A unique id for this connection, will be used to find models with matching connectionId's.

    • connectionFactory: () => Connection | Promise<Connection>

      A function that returns a mongoose connection or a Promise for a mongoose connection. The connection does not have to be alive.

        • (): Connection | Promise<Connection>
        • Returns Connection | Promise<Connection>

    • Optional connectOptions: GtConnectOptions

    Returns Promise<unknown>

findModels

  • Return all Models / Resources registered in GooseTyped

    Returns Array<Model | Resource>

getDiscriminatorKeyFor

  • getDiscriminatorKeyFor(modelClass: Ctor<any>): string | undefined
  • Returns the discriminator key for the provided Model / Resource. Only valid for discriminator implementation, thr base class will not yield a value.

    Parameters

    • modelClass: Ctor<any>

    Returns string | undefined

getDiscriminatorKeysOf

  • getDiscriminatorKeysOf(modelClass: Ctor<any>): string[]
  • Returns the discriminator keys for the provided Model / Resource.

    Parameters

    • modelClass: Ctor<any>

    Returns string[]

getEnum

  • getEnum<T>(cls: Ctor<T>, path: keyof T): string[]
  • Returns the list of enums registered for a path in a Model / Resource.

    Type parameters

    • T

    Parameters

    • cls: Ctor<T>
    • path: keyof T

    Returns string[]

getSchemaOf

  • getSchemaOf<T>(modelClass: Ctor<T>): Schema | undefined
  • Returns the mongoose schema for the provided Model / Resource

    Type parameters

    • T

    Parameters

    • modelClass: Ctor<T>

    Returns Schema | undefined

mapSchemaType

  • Parameters

    Returns void

Generated using TypeDoc