Skip to content

Commit

Permalink
Merge pull request #180 from Sourav-Tekdi/searchFieldByName
Browse files Browse the repository at this point in the history
search field option by name keyword
  • Loading branch information
Shubham4026 authored Mar 6, 2025
2 parents 6095dca + 8a82e03 commit ff5fb92
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/adapters/postgres/fields-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1457,15 +1457,16 @@ export class PostgresFieldsService implements IServicelocatorfields {
const limitCond = limit ? `limit ${limit}` : "";
let whereCond = `WHERE `;
whereCond = whereClause ? (whereCond += `${whereClause}`) : "";
// if (optionSelected) {
// if (whereCond) {
// whereCond += `AND "name" ILike '%${optionSelected}%'`;
// } else {
// whereCond += `WHERE "name" ILike '%${optionSelected}%'`;
// }
// } else {
// whereCond += "";
// }

if (optionSelected) {
if (whereCond) {
whereCond += `AND "${tableName}_name" ILike '%${optionSelected}%'`;
} else {
whereCond += `WHERE "${tableName}_name" ILike '%${optionSelected}%'`;
}
} else {
whereCond += "";
}

const query = `SELECT *,COUNT(*) OVER() AS total_count FROM public."${tableName}" ${whereCond} ${orderCond} ${offsetCond} ${limitCond}`;

Expand Down

0 comments on commit ff5fb92

Please sign in to comment.