Answer the question
In order to leave comments, you need to log in
How to find all matches in a table using typeorm?
Please tell me, there is a users table in which there is a username field, username comes to the backend request
and I need to find all matches in the table that are similar to the username that came from the client
async findUsers(username) {
const users = await this.userRepository.find({where: {username}});
return users;
}
Answer the question
In order to leave comments, you need to log in
You need to use the like operator
import { Like } from "typeorm";
const users = await this.userRepository.find({
field_to_use_for_find: Like(`%${username}%`)
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question