Download spectrum/shared/db/queries/community.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 911 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/db/queries/community.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/spectrum/shared/db/queries/community.js
-
curl -L -o community.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/spectrum/shared/db/queries/community.js
911 Bytes
| // @flow | |
| import { createReadQuery, db } from 'shared/db'; | |
| import type { DBCommunity } from 'shared/types'; | |
| export const getCommunityById = createReadQuery((id: string) => ({ | |
| query: db.table('communities').get(id), | |
| tags: (community: ?DBCommunity) => (community ? [community.id] : []), | |
| })); | |
| export const getCommunitiesById = createReadQuery((ids: Array<string>) => ({ | |
| query: db.table('communities').getAll(...ids), | |
| tags: (communities: ?Array<DBCommunity>) => | |
| communities ? communities.map(({ id }) => id) : [], | |
| })); | |
| export const getTopCommunitiesByMemberCount = createReadQuery( | |
| (amount: number) => ({ | |
| query: db | |
| .table('communities') | |
| .orderBy({ index: db.desc('memberCount') }) | |
| .filter(community => community.hasFields('deletedAt').not()) | |
| .limit(amount), | |
| tags: (communities: Array<DBCommunity>) => | |
| communities ? communities.map(({ id }) => id) : [], | |
| }) | |
| ); | |