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

17 lines
490 B
TypeScript
Raw Normal View History

2022-02-28 18:00:47 +00:00
import database from '..';
import { TAppDatabase } from '../interfaces';
import { THREAD_MESSAGES_TABLE } from '../model/ThreadMessage';
const getCollection = (db: TAppDatabase) => db.get(THREAD_MESSAGES_TABLE);
export const getThreadMessageById = async (messageId: string) => {
const db = database.active;
const threadMessageCollection = getCollection(db);
try {
const result = await threadMessageCollection.find(messageId);
return result;
} catch (error) {
return null;
}
};