Skip to content

Instantly share code, notes, and snippets.

@sostenesapollo
Created December 24, 2022 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sostenesapollo/27b539302d23ffc1a8b4e5e0e68a5168 to your computer and use it in GitHub Desktop.
Save sostenesapollo/27b539302d23ffc1a8b4e5e0e68a5168 to your computer and use it in GitHub Desktop.
Unnacent filter Prisma
const name = 'Sóstenes Apollo';
const filterText = removeAccents(`%${name}%`).toLowerCase();
console.log('Filter text', filterText);
this.prisma.$queryRaw`select
id, name
from users
where LOWER(unaccent(name)) LIKE ${filterText};`.then((users) =>
console.log(users),
);
@sostenesapollo
Copy link
Author

-- SELECT * FROM pg_available_extensions;

-- CREATE EXTENSION unaccent;

select 
    LOWER(unaccent(name)) from users 
where 
      LOWER(unaccent(name)) LIKE '%sostenes%';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment