How to use the @nestjsx/util.isArrayFull function in @nestjsx/util

To help you get started, we’ve selected a few @nestjsx/util 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 nestjsx / crud / packages / crud-typeorm / src / typeorm-crud.service.ts View on Github external
}
          // search: {$and: [{}, {}, ...]}
          else {
            this.builderAddBrackets(
              builder,
              condition,
              new Brackets((qb: any) => {
                search.$and.forEach((item: any) => {
                  this.setSearchCondition(qb, item, '$and');
                });
              }),
            );
          }
        }
        // search: {$or: [...], ...}
        else if (isArrayFull(search.$or)) {
          // search: {$or: [...]}
          if (keys.length === 1) {
            // search: {$or: [{}]}
            if (search.$or.length === 1) {
              this.setSearchCondition(builder, search.$or[0], condition);
            }
            // search: {$or: [{}, {}, ...]}
            else {
              this.builderAddBrackets(
                builder,
                condition,
                new Brackets((qb: any) => {
                  search.$or.forEach((item: any) => {
                    this.setSearchCondition(qb, item, '$or');
                  });
                }),
github nestjsx / crud / packages / crud-request / lib / request-query.parser.js View on Github external
parseQueryParam(type, parser) {
        const param = this.getParamNames(type);
        if (util_1.isArrayFull(param)) {
            return param.reduce((a, name) => [...a, ...this.getParamValues(this._query[name], parser)], []);
        }
        return [];
    }
    parseValue(val) {
github nestjsx / crud / packages / crud / src / crud / crud-routes.factory.ts View on Github external
private canCreateRoute(name: string) {
    const only = this.options.routes.only;
    const exclude = this.options.routes.exclude;

    if (isArrayFull(only)) {
      return only.some((route) => route === name);
    }

    if (isArrayFull(exclude)) {
      return !exclude.some((route) => route === name);
    }

    return true;
  }
github nestjsx / crud / packages / crud-request / src / request-query.parser.ts View on Github external
private getParamValues(value: string | string[], parser: Function): string[] {
    if (isStringFull(value)) {
      return [parser.call(this, value)];
    }

    if (isArrayFull(value)) {
      return (value as string[]).map((val) => parser(val));
    }

    return [];
  }
github nestjsx / crud / packages / crud-typeorm / lib / typeorm-crud.service.js View on Github external
async createBuilder(parsed, options, many = true) {
        const builder = this.repo.createQueryBuilder(this.alias);
        const select = this.getSelect(parsed, options.query);
        builder.select(select);
        if (util_1.isArrayFull(options.query.filter)) {
            for (let i = 0; i < options.query.filter.length; i++) {
                this.setAndWhere(options.query.filter[i], `optionsFilter${i}`, builder);
            }
        }
        const filters = [...parsed.paramsFilter, ...parsed.filter];
        const hasFilter = util_1.isArrayFull(filters);
        const hasOr = util_1.isArrayFull(parsed.or);
        if (hasFilter && hasOr) {
            if (filters.length === 1 && parsed.or.length === 1) {
                this.setOrWhere(filters[0], `filter0`, builder);
                this.setOrWhere(parsed.or[0], `or0`, builder);
            }
            else if (filters.length === 1) {
                this.setAndWhere(filters[0], `filter0`, builder);
                builder.orWhere(new typeorm_1.Brackets((qb) => {
                    for (let i = 0; i < parsed.or.length; i++) {
                        this.setAndWhere(parsed.or[i], `or${i}`, qb);
                    }
                }));
            }
            else if (parsed.or.length === 1) {
                this.setAndWhere(parsed.or[0], `or0`, builder);
github nestjsx / crud / packages / crud-typeorm / lib / typeorm-crud.service.js View on Github external
}
        }
        const joinOptions = options.query.join || {};
        const allowedJoins = util_1.objKeys(joinOptions);
        if (util_1.hasLength(allowedJoins)) {
            let eagerJoins = {};
            for (let i = 0; i < allowedJoins.length; i++) {
                if (joinOptions[allowedJoins[i]].eager) {
                    const cond = parsed.join.find((j) => j && j.field === allowedJoins[i]) || {
                        field: allowedJoins[i],
                    };
                    this.setJoin(cond, joinOptions, builder);
                    eagerJoins[allowedJoins[i]] = true;
                }
            }
            if (util_1.isArrayFull(parsed.join)) {
                for (let i = 0; i < parsed.join.length; i++) {
                    if (!eagerJoins[parsed.join[i].field]) {
                        this.setJoin(parsed.join[i], joinOptions, builder);
                    }
                }
            }
        }
        if (many) {
            const sort = this.getSort(parsed, options.query);
            builder.orderBy(sort);
            const take = this.getTake(parsed, options.query);
            if (isFinite(take)) {
                builder.take(take);
            }
            const skip = this.getSkip(parsed, take);
            if (isFinite(skip)) {
github nestjsx / crud / packages / crud-typeorm / lib / typeorm-crud.service.js View on Github external
async createBuilder(parsed, options, many = true) {
        const builder = this.repo.createQueryBuilder(this.alias);
        const select = this.getSelect(parsed, options.query);
        builder.select(select);
        if (util_1.isArrayFull(options.query.filter)) {
            for (let i = 0; i < options.query.filter.length; i++) {
                this.setAndWhere(options.query.filter[i], `optionsFilter${i}`, builder);
            }
        }
        const filters = [...parsed.paramsFilter, ...parsed.filter];
        const hasFilter = util_1.isArrayFull(filters);
        const hasOr = util_1.isArrayFull(parsed.or);
        if (hasFilter && hasOr) {
            if (filters.length === 1 && parsed.or.length === 1) {
                this.setOrWhere(filters[0], `filter0`, builder);
                this.setOrWhere(parsed.or[0], `or0`, builder);
            }
            else if (filters.length === 1) {
                this.setAndWhere(filters[0], `filter0`, builder);
                builder.orWhere(new typeorm_1.Brackets((qb) => {
                    for (let i = 0; i < parsed.or.length; i++) {