mirror of
https://github.com/logto-io/logto.git
synced 2025-01-20 21:32:31 -05:00
fb6a1dc236
* test(core): add ut for queires add ut for queries * test(core): add user query ut add user query ut * fix(core): remove test code remove console log
20 lines
599 B
TypeScript
20 lines
599 B
TypeScript
import { Roles, Role } from '@logto/schemas';
|
|
import { sql } from 'slonik';
|
|
|
|
import pool from '@/database/pool';
|
|
import { convertToIdentifiers } from '@/database/utils';
|
|
|
|
const { table, fields } = convertToIdentifiers(Roles);
|
|
|
|
export const findAllRoles = async () =>
|
|
pool.any<Role>(sql`
|
|
select ${sql.join(Object.values(fields), sql`, `)}
|
|
from ${table}
|
|
`);
|
|
|
|
export const findRolesByRoleNames = async (roleNames: string[]) =>
|
|
pool.any<Role>(sql`
|
|
select ${sql.join(Object.values(fields), sql`, `)}
|
|
from ${table}
|
|
where ${fields.name} in (${sql.join(roleNames, sql`, `)})
|
|
`);
|