Method
findBy
({
externalThreadId,
channelId,
threadId,
}: threadFindType)
Source from the content-addressed store, hash-verified
| 282 | } |
| 283 | |
| 284 | static async findBy({ |
| 285 | externalThreadId, |
| 286 | channelId, |
| 287 | threadId, |
| 288 | }: threadFindType): Promise<threadFindResponseType> { |
| 289 | return await prisma.threads.findFirst({ |
| 290 | select: { |
| 291 | id: true, |
| 292 | title: true, |
| 293 | externalThreadId: true, |
| 294 | channelId: true, |
| 295 | messages: { |
| 296 | select: { |
| 297 | body: true, |
| 298 | author: { select: { displayName: true, profileImageUrl: true } }, |
| 299 | }, |
| 300 | orderBy: { sentAt: 'asc' }, |
| 301 | take: 1, |
| 302 | }, |
| 303 | }, |
| 304 | where: { channelId, OR: [{ externalThreadId }, { id: threadId }] }, |
| 305 | }); |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | export default ThreadsServices; |
Tested by
no test coverage detected