I am new to coding and I am trying to develop new skills.
I am stuck at a point where I am trying to retrieve data based on a userid from PostgreSQL Task table.
I am using typeorm to achieve this the following is my code
async getTasks(
getTasksFilterDTO: GetTasksFilterDTO,
user: User,
): Promise<Task[]> {
const { status, search } = getTasksFilterDTO;
const query = this.createQueryBuilder('task');
query.where('task.userId = : userId', { userId: user.id });
const tasks = await query.getMany();
return tasks;
}
I am getting an error at line
query.where('task.userId = : userId', { userId: user.id });
the error is [ExceptionsHandler] syntax error at or near ":" +736ms QueryFailedError: syntax error at or near ":"
at new QueryFailedError (C:\tutorials\nestjs-task-management\node_modules\typeorm\error\QueryFailedError.js:11:28)
at Query.callback (C:\tutorials\nestjs-task-management\node_modules\typeorm\driver\postgres\PostgresQueryRunner.js:176:38)
Can someone help me to understand the mistake I was doing?