How to use the typeorm.In function in typeorm

To help you get started, we’ve selected a few typeorm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mpcast / mpcast-server / packages / core / src / service / services / categories.service.ts View on Github external
.where('obj.type = :type', { type: 'page' })
      .andWhere(where)
      // .andWhere('obj.status IN (:status)', { status: 'publish' })
      .andWhere('t.slug = :categorySlug', { categorySlug })
      .orderBy('obj.updatedAt', 'DESC')
      .offset(page)
      .limit(pageSize)
      .getRawMany();
    // 以下处理元数据
    const objIds: ID[] = [];
    data.forEach(item => {
      objIds.push(item.id);
    });
    if (!_.isEmpty(objIds)) {
      const metaData = await this.connection.getRepository(PostMeta).find({
        post: In(objIds),
      });
      data.forEach(item => {
        item.metas = _.filter(metaData, { id: item.id });
      });
    }
    return data;
  }
github mprove-io / mprove / backend / src / models / proc / process-deleted-projects.ts View on Github external
await storeMconfigs
    .delete({
      project_id: In(projectIds)
    })
    .catch(e => helper.reThrow(e, enums.storeErrorsEnum.STORE_MCONFIGS_DELETE));

  await storeModels
    .delete({
      project_id: In([projectIds])
    })
    .catch(e => helper.reThrow(e, enums.storeErrorsEnum.STORE_MODELS_DELETE));

  await storeViews
    .delete({
      project_id: In([projectIds])
    })
    .catch(e => helper.reThrow(e, enums.storeErrorsEnum.STORE_VIEWS_DELETE));

  await storeProjects
    .delete({
      project_id: In(projectIds)
    })
    .catch(e => helper.reThrow(e, enums.storeErrorsEnum.STORE_PROJECTS_DELETE));

  // disk

  await forEachSeries(projectIds, async projectId => {
    await disk
      .removePath(`${config.DISK_BACKEND_PROJECTS_PATH}/${projectId}`)
      .catch(e => helper.reThrow(e, enums.diskErrorsEnum.DISK_REMOVE_PATH));
github rjlopezdev / typeorm-express-query-builder / src / field-filter.ts View on Github external
queryToAdd = { [this.prop]: IsNull() };
        break;
      case LookupFilter.LT:
        queryToAdd = { [this.prop]: LessThan(this.value) };
        break;
      case LookupFilter.LTE:
        queryToAdd = { [this.prop]: LessThanOrEqual(this.value) };
        break;
      case LookupFilter.GT:
        queryToAdd = { [this.prop]: MoreThan(this.value) };
        break;
      case LookupFilter.GTE:
        queryToAdd = { [this.prop]: MoreThanOrEqual(this.value) };
        break;
      case LookupFilter.IN:
        queryToAdd = { [this.prop]: In(this.value.split(',')) };
        break;
      case LookupFilter.BETWEEN:
        const rangeValues = this.value.split(',');
        queryToAdd = { [this.prop]: Between(+rangeValues[0], +rangeValues[1]) };
        break;
    }
    if(this.notOperator) {
      queryToAdd[this.prop] = Not(queryToAdd[this.prop]);
    }
    this.query['where'] = {
      ...this.query['where'],
      ...queryToAdd
    }
  }
}
github mpcast / mpcast-server / packages / core / dist / service / services / term.service.js View on Github external
.innerJoin(query => {
            return query.from(common_1.Post, 'obj');
        }, 'obj', 'obj.id = tr.objectId')
            .where('obj.type = :type', { type: 'page' })
            .andWhere('obj.status IN (:status)', { status: 'publish' })
            .andWhere('tt.taxonomy = :category', { category: 'category' })
            .orderBy('obj.updatedAt', 'DESC')
            .limit(limit)
            .getRawMany();
        const objIds = [];
        data.forEach(item => {
            objIds.push(item.id);
        });
        if (!_.isEmpty(objIds)) {
            const metaData = await this.connection.getRepository(entity_1.PostMeta).find({
                post: typeorm_2.In(objIds),
            });
            data.forEach(item => {
                item.metas = _.filter(metaData, { id: item.id });
            });
        }
        return data;
    }
    async getStickys(stickys) {
github danielwii / asuna-node-server / src / modules / core / db / db.helper.ts View on Github external
function parseCondition(value: Condition): string | Condition | FindOperator {
  if (_.has(value, '$and')) {
    return { $and: R.map(parseCondition)(value.$and) };
  }
  if (_.has(value, '$or')) {
    return { $or: R.map(parseCondition)(value.$or) };
  }

  if (_.has(value, '$like')) return Like(value.$like);
  if (_.has(value, '$notLike')) return Not(Like(value.$notLike));
  if (_.has(value, '$any')) return Any(value.$any);
  if (_.has(value, '$in')) return In(_.isArray(value.$in) ? value.$in : [value.$in]);
  if (_.has(value, '$notIn')) return Not(In(value.$notIn));
  if (_.has(value, '$between')) return Between(value.$between[0], value.$between[1]);
  if (_.has(value, '$eq')) return Equal(value.$eq);
  if (_.has(value, '$lt')) return LessThan(value.$lt);
  if (_.has(value, '$gt')) return MoreThan(value.$gt);
  if (_.has(value, '$raw')) return Raw(value.$raw);
  if (_.has(value, '$notNull')) return Not(IsNull());
  if (_.has(value, '$isNull')) return IsNull();
  if (_.has(value, '$not')) return Not(value.$not);
  if (_.isBoolean(value) || _.isString(value)) return value;
  logger.warn(`no handler found for '${r(value)}'`);
  return value;
}
github birkir / prime / packages / prime-core / src / utils / DocumentTransformer.ts View on Github external
public getFields = async (schema: Schema): Promise => {
    const schemaIds: string[] = [schema.id];

    if (schema) {
      schemaIds.push(...get(schema, 'settings.schemaIds', []));
    }

    const fields = await getRepository(SchemaField).find({
      where: {
        schemaId: In(schemaIds),
      },
      cache: 1000,
    });

    return fields;
  };
github xmlking / ngx-starter-kit / apps / api / src / app / notifications / notification / notification.service.ts View on Github external
async findOwn({ take, skip, order }: FindOwnNotificationsDto, actor: User): Promise> {
    const criteria = new FindNotificationsDto({
      target: In(['all', actor.username]),
      isActive: true,
      take,
      skip,
      order,
    });
    return super.findAll(criteria);
  }
github SolidZORO / leaa / packages / leaa-api / src / modules / setting / setting.service.ts View on Github external
.then(async () => {
        items = await this.settingRepository.find({ id: In(settings.map(s => s.id)) });
      })
      .catch(() => {
github birkir / prime / packages / prime-core / src / modules / internal / utils / setSchemaFields.ts View on Github external
return field;
  };

  for (const group of groups) {
    if (group.fields) {
      await Promise.all(
        group.fields.map((children, i) => {
          return updateOrCreateField(children, group.title, i);
        })
      );
    }
  }

  if (fieldsToBeRemovedSet.size > 0) {
    await schemaFieldRepo.delete({
      id: In(Array.from(fieldsToBeRemovedSet)),
    });
  }

  const schema = await schemaRepo.findOne(schemaId);

  if (schema) {
    schema.groups = groups.map(group => group.title);
    await schemaRepo.save(schema);
  }

  return true;
};
github SolidZORO / leaa / packages / leaa-api / src / modules / attachment / attachment.service.ts View on Github external
.then(async () => {
        loggerUtil.log(JSON.stringify(attachments), CLS_NAME);

        items = await this.attachmentRepository.find({ uuid: In(attachments.map(a => a.uuid)) });
      })
      .catch(() => {