typeorm#UpdateResult TypeScript Examples

The following examples show how to use typeorm#UpdateResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: message.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async readMessages(
    recipient: UserEntity,
    readMessageDto: ReadMessageDto,
  ): Promise<UpdateResult> {
    const queryBuilder = this._messageRepository.createQueryBuilder('message');

    if (readMessageDto.uuid) {
      return queryBuilder
        .update()
        .set({ readed: true })
        .where('recipient = :recipient', { recipient: recipient.id })
        .andWhere('uuid = :uuid', { uuid: readMessageDto.uuid })
        .execute();
    }

    return queryBuilder
      .update()
      .set({ readed: true })
      .where('recipient = :recipient', { recipient: recipient.id })
      .execute();
  }
Example #2
Source File: transaction.service.ts    From bank-server with MIT License 6 votes vote down vote up
private async _updateTransactionAuthorizationStatus(
    transaction: TransactionEntity,
  ): Promise<UpdateResult> {
    const queryBuilder = this._transactionRepository.createQueryBuilder(
      'transaction',
    );

    return queryBuilder
      .update()
      .set({ authorizationStatus: true })
      .where('id = :id', { id: transaction.id })
      .execute();
  }
Example #3
Source File: user-auth-forgotten-password.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async changeTokenActiveStatus(
    userAuthForgottenPasswordEntity: UserAuthForgottenPasswordEntity,
    status: boolean,
  ): Promise<UpdateResult> {
    /**
     * password is automatically encrypted by beforeUpdate subscriber
     * reference: UserAuthSubscriber
     */
    return this._userAuthForgottenPasswordRepository.update(
      userAuthForgottenPasswordEntity.id,
      { used: status },
    );
  }
Example #4
Source File: user-auth.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async updateLastLogoutDate(
    userAuth: UserAuthEntity,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userAuthRepository.createQueryBuilder(
      'userAuth',
    );

    return queryBuilder
      .update()
      .set({ lastLogoutDate: new Date() })
      .where('id = :id', { id: userAuth.id })
      .execute();
  }
Example #5
Source File: user-auth.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async updateRole(
    userAuth: UserAuthEntity,
    role: RoleType,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userAuthRepository.createQueryBuilder(
      'userAuth',
    );

    return queryBuilder
      .update()
      .set({ role })
      .where('id = :id', { id: userAuth.id })
      .execute();
  }
Example #6
Source File: user-auth.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async updatePassword(
    userAuth: UserAuthEntity,
    password: string,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userAuthRepository.createQueryBuilder(
      'userAuth',
    );

    return queryBuilder
      .update()
      .set({ password })
      .where('id = :id', { id: userAuth.id })
      .execute();
  }
Example #7
Source File: user-auth.service.ts    From bank-server with MIT License 6 votes vote down vote up
private async _updateLastFailedLoggedDate(
    userAuth: UserAuthEntity,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userAuthRepository.createQueryBuilder(
      'userAuth',
    );

    return queryBuilder
      .update()
      .set({ lastFailedLoggedDate: new Date() })
      .where('id = :id', { id: userAuth.id })
      .execute();
  }
Example #8
Source File: user-auth.service.ts    From bank-server with MIT License 6 votes vote down vote up
private async _updateLastSuccessfulLoggedDate(
    userAuth: UserAuthEntity,
    lastPresentLoggedDate?: Date,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userAuthRepository.createQueryBuilder(
      'userAuth',
    );

    return queryBuilder
      .update()
      .set({ lastSuccessfulLoggedDate: lastPresentLoggedDate ?? new Date() })
      .where('id = :id', { id: userAuth.id })
      .execute();
  }
Example #9
Source File: user-config.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async updateLastPresentLoggedDate(
    userConfig: UserConfigEntity,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userConfigRepository.createQueryBuilder(
      'userConfig',
    );

    return queryBuilder
      .update()
      .set({ lastPresentLoggedDate: new Date() })
      .where('id = :id', { id: userConfig.id })
      .execute();
  }
Example #10
Source File: user-config.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async updateMainCurrency(
    userConfig: UserConfigEntity,
    currency: CurrencyEntity,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userConfigRepository.createQueryBuilder(
      'userConfig',
    );

    return queryBuilder
      .update()
      .set({ currency })
      .where('id = :id', { id: userConfig.id })
      .execute();
  }
Example #11
Source File: user-config.service.ts    From bank-server with MIT License 6 votes vote down vote up
public async setNotification(
    userConfig: UserConfigEntity,
    reset = false,
  ): Promise<UpdateResult> {
    const queryBuilder = this._userConfigRepository.createQueryBuilder(
      'userConfig',
    );

    return queryBuilder
      .update()
      .set({
        notificationCount: () => (reset ? '0' : 'notification_count + 1'),
      })
      .where('id = :id', { id: userConfig.id })
      .execute();
  }