typeorm 模糊查询

由于官网文档没有给出详细的说明,故在此做简要的文档记录

如下所示:

      async fuzzySearch(name: string){
      const postRepository = connection.getRepository(Post);
      return  await postRepository.createQueryBuilder("post")
                .where("post.title LIKE :param")
                .setParameters({
                    param: '%'+name+'%'
                })
                .orderBy("post.id", "ASC")
                .getMany();
      }

猜你喜欢

转载自blog.csdn.net/weixin_34273481/article/details/87395370
今日推荐