How to get pg_locks related to a specific database in Postgres?
As documented in the manual pg_locks contains a column database which you can join to the pg_database view:
select l.*
from pg_locks l
  join pg_database d on d.oid = l.database
where d.datname = current_database();