Download spectrum/api/models/reaction.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 912 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/models/reaction.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/api/models/reaction.js
-
curl -L -o reaction.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/api/models/reaction.js
912 Bytes
| // @flow | |
| import { db } from 'shared/db'; | |
| import type { DBReaction } from 'shared/types'; | |
| type ReactionType = 'like'; | |
| export type ReactionInput = { | |
| messageId: string, | |
| type: ReactionType, | |
| }; | |
| // prettier-ignore | |
| export const getReactions = (messageIds: Array<string>): Promise<Array<DBReaction>> => { | |
| const distinctMessageIds = messageIds.filter((x, i, a) => a.indexOf(x) == i); | |
| return db | |
| .table('reactions') | |
| .getAll(...distinctMessageIds, { index: 'messageId' }) | |
| .filter(row => row.hasFields('deletedAt').not()) | |
| .group('messageId') | |
| .run(); | |
| }; | |
| export const getReaction = (reactionId: string): Promise<DBReaction> => { | |
| return db | |
| .table('reactions') | |
| .get(reactionId) | |
| .run(); | |
| }; | |
| // prettier-ignore | |
| export const getReactionsByIds = (reactionIds: Array<string>): Promise<Array<DBReaction>> => { | |
| return db | |
| .table('reactions') | |
| .getAll(...reactionIds) | |
| .run(); | |
| }; | |