How to perform a like query Typeorm

后端 未结 5 624
北海茫月
北海茫月 2020-12-30 22:40

Hello guys I\'m trying to find all the results that have a in them. I have tried a couple of ways but the problem is nothing works. It just returns an empty array

5条回答
  •  遥遥无期
    2020-12-30 23:07

    TypeORM provides out of the box Like function. Example from their docs:

    import {Like} from "typeorm";
    
    const loadedPosts = await connection.getRepository(Post).find({
        title: Like("%out #%")
    });
    

    in your case:

    var data = await getRepository(User).find({
        name: Like(`%${firstName}%`)
    });
    

提交回复
热议问题