UNPKG

@iexec/dataprotector

Version:

This product enables users to confidentially store data–such as mail address, documents, personal information ...

67 lines 1.84 kB
import { gql } from 'graphql-request'; import { throwIfMissing } from '../../../utils/validators.js'; export const getProtectedDataInCollectionsQuery = async ({ graphQLClient = throwIfMissing(), protectedData, collectionId, collectionOwner, createdAfterTimestamp, isRentable, isForSale, page, pageSize, }) => { const start = page * pageSize; const range = pageSize; const protectedDatas = gql ` query ( $start: Int! $range: Int! ) { protectedDatas( where: { ${protectedData ? `id: "${protectedData}",` : ''}, ${isRentable ? `isRentable: ${isRentable},` : ''}, ${isForSale ? `isForSale: ${isForSale},` : ''}, ${collectionId ? `collection: "${collectionId}",` : `collection_not: "null"`}, ${collectionOwner ? `collection_ : { owner: "${collectionOwner}" }` : ''}, ${createdAfterTimestamp ? `creationTimestamp_gte: "${createdAfterTimestamp}",` : ''} } skip: $start first: $range orderBy: creationTimestamp orderDirection: desc ) { id name creationTimestamp owner { id } collection { id owner { id } } isRentable rentalParams { price duration } rentals { renter, endDate } isForSale saleParams { price } isIncludedInSubscription } } `; //in case of a large number of protected data, we need to paginate the query const variables = { start, range, }; return graphQLClient.request(protectedDatas, variables); }; //# sourceMappingURL=getProtectedDataInCollectionsQuery.js.map