Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseModel

Represents an abstract base model that every model inherits from.

Hierarchy

  • BaseModel

Index

Properties

id

id: number

Methods

belongsTo

  • belongsTo<A, T, K>(model: T, foreignKey?: K): R<A>
  • Indicates that this object has a single associated object of the provided model type. The object will be looked up by looking at the value of the specified column and finding the row of the specified model with that ID.

    Type parameters

    • A

    • T: Wrapped<any, A>

    • K: keyof this

    Parameters

    • model: T
    • Optional foreignKey: K

    Returns R<A>

builder

delete

  • delete(): Promise<void>
  • Deletes this object, throwing if it is not currently stored.

    Returns Promise<void>

hasAndBelongsToMany

  • hasAndBelongsToMany<Q, T>(model: T, pivotName?: undefined | string): A<Q>
  • Relationship that functions as a hasMany going both ways. This requires a pivot table which joins the two models together.

    Type parameters

    Parameters

    • model: T
    • Optional pivotName: undefined | string

    Returns A<Q>

hasMany

  • hasMany<Q, T>(model: T, foreignKey?: undefined | string): A<Q>
  • Relationship that finds all members of the specified model table with their foreign key set to the ID of the current object.

    Type parameters

    Parameters

    • model: T
    • Optional foreignKey: undefined | string

    Returns A<Q>

hasOne

  • hasOne<A, T>(model: T, foreignKey?: undefined | string): R<A>
  • Indicates that this object has a single associated object of the provided model type and optional foreign key (which will default to the name of the current model with _id).

    Type parameters

    Parameters

    • model: T
    • Optional foreignKey: undefined | string

    Returns R<A>

save

  • save(): Promise<void>
  • Saves this object, inserting it if it doesn't exist or updating it otherwise.

    Returns Promise<void>

Generated using TypeDoc