@deep/nest-kit
    Preparing search index...

    Class BaseUser

    The User Entity is a data schema that represents a user within your application. It typically includes fields such as the user's name, email address, password, and other profile information.

    Hierarchy

    • BaseEntity
      • BaseUser

    Implements

    Index

    Constructors

    Properties

    avatarUrl?: MaybeNull<string>

    User's avatar URL

    'https://example.com/avatar.png'
    
    clientId?: MaybeNull<string>

    Client ID (for Apollo Studio)

    createdAt: Date

    Date, when user was created.

    deletedAt?: MaybeNull<Date>

    Date, when user was deleted.

    email: string

    Users's email. Must be unique.

    '[email protected]'
    
    firstName: string

    User's first name

    'John'
    
    id: string
    invitationStatus: UserInvitationStatus

    When user is invited to the system, it has one of the following statuses:

    invitationStatusChanges: Promise<InvitationStatusChange[]>
    is2faEnabled?: MaybeNull<boolean>

    Represent Two-Factor Authentication status.

    isOtpEnabled?: MaybeNull<boolean>

    Represent One-Time Password status.

    lastName: string

    User's last name

    'Doe'
    
    lastSeen: Date

    Date, when user made last request to the system.

    locale?: MaybeNull<string>

    User's locale in ISO 639-1 format. Use LanguagesModule to fetch lists with locales.

    'en'
    
    otpSecret?: MaybeNull<string>

    Keep One-Time Password secret.

    parentUserId?: MaybeNull<string>

    Parent user who was signed in as this user.

    passwordHash?: MaybeNull<string>

    User's password hash. Generated from real password by bcrypt. When user logged in with password, password hash is compared with this field.

    patronymic?: MaybeNull<string>

    User's patronymic name

    'Ivanovich'
    
    permissions: string[] = []

    User's custom permissions. In general, permissions must be inherited from roles. But you can add custom permissions to user.

    [
    'js:core:episodes:create',
    'js:core:episodes:update'
    ]
    phoneNumber?: MaybeNull<string>

    User's phone number

    '+380501234567'
    
    referrer?: MaybeNull<string>

    User's referrer. It can be email or any other identifier.

    '[email protected]'
    
    resolvedPermissions: ReadonlyResolvedPermission[] = []

    User's resolved permissions. This array is used by authorization guards to check user's permissions. This array must be fullfilled by UserManager.resolve when user tries to make request.

    [
    {
    id: 'js:core:episodes:create',
    scopes: ['org#hcorg:xxxxxxxxxx']
    },
    ...
    ]
    status: UserStatus

    Users has two statuses: ACTIVE and DELETED.

    ACTIVE - user is active and can signin to the system. DELETED - user is deleted and can't signin to the system.

    timezoneName?: MaybeNull<string>

    User's timezone name in IANA format. Use TimezonesModule to fetch lists with timezones.

    'Europe/Kiev'
    
    type: UserType

    Users has two types: USER and SA.

    updatedAt: Date

    Date, when user was updated.

    userToRoles: Promise<BaseUserToRole[]>

    User's roles.

    Accessors

    • get fullName(): string

      User's full name computed from first and last name

      Returns string

      'John Doe'
      
    • get isDeleted(): boolean

      Returns boolean

    • get target(): EntityTarget<any>

      Returns object that is managed by this repository. If this repository manages entity from schema, then it returns a name of that schema instead.

      Returns EntityTarget<any>

    Methods

    • Checks if entity has an id. If entity composite compose ids, it will check them all.

      Returns boolean

    • Recovers a given entity in the database.

      Parameters

      • Optionaloptions: SaveOptions

      Returns Promise<BaseUser>

    • Reloads entity data from the database.

      Returns Promise<void>

    • Removes current entity from the database.

      Parameters

      • Optionaloptions: RemoveOptions

      Returns Promise<BaseUser>

    • Saves current entity in the database. If entity does not exist in the database then inserts, otherwise updates.

      Parameters

      • Optionaloptions: SaveOptions

      Returns Promise<BaseUser>

    • Records the delete date of current entity.

      Parameters

      • Optionaloptions: SaveOptions

      Returns Promise<BaseUser>

    • Return the AVG of a column

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • columnName: PickKeysByType<T, number>
      • where: FindOptionsWhere<T>

      Returns Promise<null | number>

    • Clears all the data from the given table/collection (truncates/drops it).

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity

      Returns Promise<void>

    • Counts entities that match given options.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • Optionaloptions: FindManyOptions<T>

      Returns Promise<number>

    • Counts entities that match given WHERE conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • where: FindOptionsWhere<T>

      Returns Promise<number>

    • Creates a new entity instance.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity

      Returns T

    • Creates a new entities and copies all entity properties from given objects into their new entities. Note that it copies only properties that present in entity schema.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entityLikeArray: DeepPartial<T>[]

      Returns T[]

    • Creates a new entity instance and copies all entity properties from this object into a new entity. Note that it copies only properties that present in entity schema.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entityLike: DeepPartial<T>

      Returns T

    • Creates a new query builder that can be used to build a SQL query.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • Optionalalias: string

      Returns SelectQueryBuilder<T>

    • Deletes entities by a given criteria. Unlike remove method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient DELETE query. Does not check if entity exist in the database.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • criteria:
            | string
            | number
            | string[]
            | Date
            | number[]
            | ObjectId
            | Date[]
            | ObjectId[]
            | FindOptionsWhere<T>

      Returns Promise<DeleteResult>

    • Checks whether any entity exists that matches the given options.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • Optionaloptions: FindManyOptions<T>

      Returns Promise<boolean>

    • Checks whether any entity exists that matches the given conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • where: FindOptionsWhere<T>

      Returns Promise<boolean>

    • Finds entities that match given options.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • Optionaloptions: FindManyOptions<T>

      Returns Promise<T[]>

    • Finds entities that match given find options. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • Optionaloptions: FindManyOptions<T>

      Returns Promise<[T[], number]>

    • Finds entities that match given WHERE conditions. Also counts all entities that match given conditions, but ignores pagination settings (from and take options).

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • where: FindOptionsWhere<T>

      Returns Promise<[T[], number]>

    • Finds entities that match given WHERE conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • where: FindOptionsWhere<T>

      Returns Promise<T[]>

    • Finds entities by ids. Optionally find options can be applied.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • ids: any[]

      Returns Promise<T[]>

      use findBy method instead in conjunction with In operator, for example:

      .findBy({ id: In([1, 2, 3]) })

    • Finds first entity that matches given conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • options: FindOneOptions<T>

      Returns Promise<null | T>

    • Finds first entity that matches given conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • where: FindOptionsWhere<T>

      Returns Promise<null | T>

    • Finds first entity that matches given options.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • id: string | number | Date | ObjectId

      Returns Promise<null | T>

      use findOneBy method instead in conjunction with In operator, for example:

      .findOneBy({ id: 1 // where "id" is your primary column name })

    • Finds first entity that matches given conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • where: FindOptionsWhere<T>

      Returns Promise<T>

    • Finds first entity that matches given conditions.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • options: FindOneOptions<T>

      Returns Promise<T>

    • Gets entity mixed id.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entity: T

      Returns any

    • Gets current entity's Repository.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity

      Returns Repository<T>

    • Checks entity has an id. If entity composite compose ids, it will check them all.

      Parameters

      • entity: BaseEntity

      Returns boolean

    • Inserts a given entity into the database. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT query. Does not check if entity exist in the database, so query will fail if duplicate entity is being inserted.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entity:
            | _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>
            | _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>[]

      Returns Promise<InsertResult>

    • Return the MAX of a column

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • columnName: PickKeysByType<T, number>
      • where: FindOptionsWhere<T>

      Returns Promise<null | number>

    • Merges multiple entities (or entity-like objects) into a given entity.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • mergeIntoEntity: T
      • ...entityLikes: DeepPartial<T>[]

      Returns T

    • Return the MIN of a column

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • columnName: PickKeysByType<T, number>
      • where: FindOptionsWhere<T>

      Returns Promise<null | number>

    • Creates a new entity from the given plain javascript object. If entity already exist in the database, then it loads it (and everything related to it), replaces all values with the new ones from the given object and returns this new entity. This new entity is actually a loaded from the db entity with all properties replaced from the new object.

      Note that given entity-like object must have an entity id / primary key to find entity by. Returns undefined if entity with given id was not found.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entityLike: DeepPartial<T>

      Returns Promise<undefined | T>

    • Executes a raw SQL query and returns a raw database results. Raw query execution is supported only by relational databases (MongoDB is not supported).

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • query: string
      • Optionalparameters: any[]

      Returns Promise<any>

    • Removes a given entities from the database.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entities: T[]
      • Optionaloptions: RemoveOptions

      Returns Promise<T[]>

    • Removes a given entity from the database.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entity: T
      • Optionaloptions: RemoveOptions

      Returns Promise<T>

    • Saves all given entities in the database. If entities do not exist in the database then inserts, otherwise updates.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entities: DeepPartial<T>[]
      • Optionaloptions: SaveOptions

      Returns Promise<T[]>

    • Saves a given entity in the database. If entity does not exist in the database then inserts, otherwise updates.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entity: DeepPartial<T>
      • Optionaloptions: SaveOptions

      Returns Promise<T>

    • Records the delete date of all given entities.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entities: T[]
      • Optionaloptions: SaveOptions

      Returns Promise<T[]>

    • Records the delete date of a given entity.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entity: T
      • Optionaloptions: SaveOptions

      Returns Promise<T>

    • Return the SUM of a column

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • columnName: PickKeysByType<T, number>
      • where: FindOptionsWhere<T>

      Returns Promise<null | number>

    • Updates entity partially. Entity can be found by a given conditions. Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient UPDATE query. Does not check if entity exist in the database.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • criteria:
            | string
            | number
            | string[]
            | Date
            | number[]
            | ObjectId
            | Date[]
            | ObjectId[]
            | FindOptionsWhere<T>
      • partialEntity: QueryDeepPartialEntity<T>

      Returns Promise<UpdateResult>

    • Inserts a given entity into the database, unless a unique constraint conflicts then updates the entity Unlike save method executes a primitive operation without cascades, relations and other operations included. Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query.

      Type Parameters

      • T extends BaseEntity

      Parameters

      • this: new () => T & typeof BaseEntity
      • entityOrEntities:
            | _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>
            | _QueryDeepPartialEntity<ObjectLiteral extends T ? unknown : T>[]
      • conflictPathsOrOptions: string[] | UpsertOptions<T>

      Returns Promise<InsertResult>

    • Sets DataSource to be used by entity.

      Parameters

      • dataSource: null | DataSource

      Returns void