How to use the typeorm.Like 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 xpioneer / koa-graphql-typescript / src / controllers / ArticleController.ts View on Github external
static async pages(args: any) {
    console.log(args, 'query args ===================')
    const options: FindManyOptions<article> = {
      skip: args.page &lt; 2 ? 0 : (args.page - 1) * args.pageSize,
      take: args.pageSize,
      order: {},
      where: {
        deletedAt: null
      }
    }
    if(args.title) {
      options.where['title'] = Like(`%${args.title}%`)
    }
    if(args.abstract) {
      options.where['abstract'] = Like(`%${args.abstract}%`)
    }
    if(args.tag) {
      options.where['tag'] = Like(`%${args.tag}%`)
    }
    if(args.createdAt) {
      const date = args.createdAt.map((c: string) =&gt; (Moment(c)).valueOf())
      options.where['createdAt'] = Between(date[0], date[1])
    }
    if(args.order) {
      options.order = Object.assign(options.order, args.order)
    }
    console.log(options, '----options')

    const pages = await getRepository(Article).findAndCount(options)
      // .createQueryBuilder()
      // .where({</article>
github rjlopezdev / typeorm-express-query-builder / test / unit / field-filter.spec.ts View on Github external
it('should return a  filter', () =&gt; {
    const fieldFilter = new FieldFilter(built, 'name', LookupFilter.CONTAINS, 'value');
    fieldFilter.buildQuery();
    expect(built['where']['name']).toEqual(Like('%value%'));
  });
github rjlopezdev / typeorm-express-query-builder / test / integration / express / express.spec.ts View on Github external
.end((err, res) => {
        expect(JSON.parse(res.text)).toEqual({
          where: {
            name: 'rjlopezdev',
            email: Like('%@gmail.com%')
          },
          skip: 0,
          take: 25
        });
        done();
      })
  })
github xpioneer / koa-graphql-typescript / src / controllers / ArticleController.ts View on Github external
static async pages(args: any) {
    console.log(args, 'query args ===================')
    const options: FindManyOptions<article> = {
      skip: args.page &lt; 2 ? 0 : (args.page - 1) * args.pageSize,
      take: args.pageSize,
      order: {},
      where: {
        deletedAt: null
      }
    }
    if(args.title) {
      options.where['title'] = Like(`%${args.title}%`)
    }
    if(args.abstract) {
      options.where['abstract'] = Like(`%${args.abstract}%`)
    }
    if(args.tag) {
      options.where['tag'] = Like(`%${args.tag}%`)
    }
    if(args.createdAt) {
      const date = args.createdAt.map((c: string) =&gt; (Moment(c)).valueOf())
      options.where['createdAt'] = Between(date[0], date[1])
    }
    if(args.order) {
      options.order = Object.assign(options.order, args.order)
    }
    console.log(options, '----options')
</article>
github Aionic-Apps / aionic-core / src / api / components / milestone / task / controller.ts View on Github external
public async readTasks(req: Request, res: Response, next: NextFunction): Promise {
		try {
			const { title, term, status, assignee, author, tag, organization, branch } = req.query;

			let where: FindConditions = {};

			if (title &amp;&amp; title.length) {
				where = { ...where, title: Like(`%${title}%`) };
			}

			if (term &amp;&amp; term.length) {
				where = { ...where, description: Like(`%${term}%`) };
			}

			if (status) {
				where = { ...where, status: { id: status } };
			}

			if (assignee) {
				where = { ...where, assignee: { id: assignee } };
			}

			if (author) {
				where = { ...where, author: { id: author } };
github Aionic-Apps / aionic-core / src / api / components / milestone / task / controller.ts View on Github external
public async readTasks(req: Request, res: Response, next: NextFunction): Promise {
		try {
			const { title, term, status, assignee, author, tag, organization, branch } = req.query;

			let where: FindConditions = {};

			if (title &amp;&amp; title.length) {
				where = { ...where, title: Like(`%${title}%`) };
			}

			if (term &amp;&amp; term.length) {
				where = { ...where, description: Like(`%${term}%`) };
			}

			if (status) {
				where = { ...where, status: { id: status } };
			}

			if (assignee) {
				where = { ...where, assignee: { id: assignee } };
			}

			if (author) {
				where = { ...where, author: { id: author } };
			}

			if (tag &amp;&amp; tag.length) {
				where = { ...where, tags: Like(`%${tag}%`) };
github xpioneer / koa-graphql-typescript / src / controllers / CommentController.ts View on Github external
static async pages(args: any) {
    const options: FindManyOptions = {
      skip: args.page &lt; 2 ? 0 : (args.page - 1) * args.pageSize,
      take: args.pageSize,
      order: {},
      where: {
        deletedAt: null
      }
    }
    if(args.description) {
      options.where['description'] = Like(`%${args.description}%`)
    }
    if(args.createdAt) {
      const date = args.createdAt.map((c: string) =&gt; (Moment(c)).valueOf())
      options.where['createdAt'] = Between(date[0], date[1])
    }
    if(args.order) {
      options.order = Object.assign(options.order, args.order)
    }
    const pages = await getRepository('comment').findAndCount(options)
    return pages
  }
github ConnextProject / indra / modules / node / src / cfCore / cfCore.repository.ts View on Github external
async findRecordsForRestore(multisigAddress: string): Promise {
    return await this.find({ path: Like(`%${multisigAddress}`) });
  }
}
github vendure-ecommerce / vendure / server / src / service / services / product-option-group.service.ts View on Github external
findAll(lang: LanguageCode, filterTerm?: string): Promise&gt;&gt; {
        const findOptions: FindManyOptions = {
            relations: ['options'],
        };
        if (filterTerm) {
            findOptions.where = {
                code: Like(`%${filterTerm}%`),
            };
        }
        return this.connection.manager
            .find(ProductOptionGroup, findOptions)
            .then(groups =&gt; groups.map(group =&gt; translateDeep(group, lang, ['options'])));
    }
github Aionic-Apps / aionic-core / src / rest / components / search / controller.ts View on Github external
public async searchTaskByDescription(
    req: Request,
    res: Response,
    next: NextFunction
  ): Promise {
    try {
      const { title, searchTerm, status, assignee, author, branch, closed } = req.query

      let where = {}

      if (title &amp;&amp; title.length) {
        where = { ...where, title: Like(`%${title}%`) }
      }

      if (searchTerm &amp;&amp; searchTerm.length) {
        where = { ...where, description: Like(`%${searchTerm}%`) }
      }

      if (status) {
        where = { ...where, status: { id: status } }
      }

      if (assignee) {
        where = { ...where, assignee: { id: assignee } }
      }

      if (author) {
        where = { ...where, author: { id: author } }