Download spectrum/api/models/usersThreads.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/usersThreads.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/usersThreads.js
-
curl -L -o usersThreads.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/spectrum/api/models/usersThreads.js
1.09 kB
| // @flow | |
| import type { DBUsersThreads } from 'shared/types'; | |
| const { db } = require('shared/db'); | |
| // prettier-ignore | |
| export const deleteParticipantInThread = (threadId: string, userId: string): Promise<boolean> => { | |
| return db | |
| .table('usersThreads') | |
| .getAll([userId, threadId], { index: 'userIdAndThreadId' }) | |
| .delete() | |
| .run() | |
| }; | |
| // prettier-ignore | |
| export const getParticipantsInThread = (threadId: string): Promise<Array<Object>> => { | |
| return db | |
| .table('usersThreads') | |
| .getAll(threadId, { index: 'threadId' }) | |
| .filter({ isParticipant: true }) | |
| .eqJoin('userId', db.table('users')) | |
| .without({ | |
| left: ['createdAt', 'id', 'threadId', 'userId'], | |
| }) | |
| .zip() | |
| .run(); | |
| }; | |
| export const getParticipantsInThreads = (threadIds: Array<string>) => { | |
| return db | |
| .table('usersThreads') | |
| .getAll(...threadIds, { index: 'threadId' }) | |
| .filter({ isParticipant: true }) | |
| .eqJoin('userId', db.table('users')) | |
| .group(rec => rec('left')('threadId')) | |
| .without({ | |
| left: ['createdAt', 'id', 'userId'], | |
| }) | |
| .zip() | |
| .run(); | |
| }; | |