Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 1x 1x 1x 1x 77x 77x 77x 77x 77x 77x 77x 1x | import { mergeQuery } from "feathers-utils"; import getFieldsQueryFor from "./getFieldsQueryFor"; import getConditionalQueryFor from "./getConditionalQueryFor"; import { Query } from "@feathersjs/feathers"; import { AnyAbility } from "@casl/ability"; import { GetQueryOptions } from "../types"; const getQueryFor = ( ability: AnyAbility, method: string, modelName: string, options?: GetQueryOptions ): Query => { options = options || { availableFields: [] }; const { skipConditional, skipFields } = options; Iif (skipConditional && skipFields) { return {}; } const conditionsQuery = (!skipConditional) ? getConditionalQueryFor(ability, method, modelName, { actionOnForbidden: options.actionOnForbidden }) : {}; const fieldsQuery = (!skipFields) ? getFieldsQueryFor(ability, method, modelName, { availableFields: options.availableFields }) : {}; const query = mergeQuery(conditionsQuery, fieldsQuery, { defaultHandle: "combine" }); return query; }; export default getQueryFor; |