verdnatura-chat/app/lib/database/services/Role.ts

18 lines
494 B
TypeScript
Raw Normal View History

2022-02-28 18:00:47 +00:00
import database from '..';
import { TAppDatabase } from '../interfaces';
import { ROLES_TABLE } from '../model';
import { TRoleModel } from '../../../definitions';
const getCollection = (db: TAppDatabase) => db.get(ROLES_TABLE);
export const getRoleById = async (id: string): Promise<TRoleModel | null> => {
const db = database.active;
const roleCollection = getCollection(db);
try {
const result = await roleCollection.find(id);
return result;
} catch (error) {
return null;
}
};