typeorm#WhereExpressionBuilder TypeScript Examples

The following examples show how to use typeorm#WhereExpressionBuilder. 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: util.ts    From context-mod with MIT License 7 votes vote down vote up
orByRelatedActivities = (activity: Activity, qb: WhereExpressionBuilder): void => {
    if(activity.type === 'comment' && activity.submission !== undefined) {
        qb.where('activity._id = :actId', {actId: activity.id})
            .orWhere('activity._id = :subId', {subId: activity.submission?.id});
    } else if (activity.type === 'submission') {
        qb.where('activity._id = :actId', {actId: activity.id})
            .orWhere('activitySubmission._id = :subId', {subId: activity.id});
    }
}
Example #2
Source File: util.ts    From context-mod with MIT License 6 votes vote down vote up
orByRelatedAuthor = (activity: Activity, qb: WhereExpressionBuilder): void => {
    qb.where('author.name = :authorName', {authorName: activity.author.name});
}
Example #3
Source File: Paginator.ts    From typeorm-cursor-pagination with MIT License 6 votes vote down vote up
private buildCursorQuery(
    where: WhereExpressionBuilder,
    cursors: CursorParam,
  ): void {
    const operator = this.getOperator();
    const params: CursorParam = {};
    this.paginationKeys.forEach((key) => {
      params[key] = cursors[key];
      where.andWhere(
        new Brackets((qb) => {
          const paramsHolder = {
            [`${key}_1`]: params[key],
            [`${key}_2`]: params[key],
          };
          qb.where(`${this.alias}.${key} ${operator} :${key}_1`, paramsHolder);
          if (this.paginationUniqueKey !== key) {
            qb.orWhere(`${this.alias}.${key} = :${key}_2`, paramsHolder);
          }
        }),
      );
    });
  }