From c7bc4143bc4837d1d18cbc07484af7e39685b165 Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 12 Jun 2025 11:26:28 +0100 Subject: [PATCH] fix: add utilty function --- api/src/utils/helpers/criteria.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 api/src/utils/helpers/criteria.ts diff --git a/api/src/utils/helpers/criteria.ts b/api/src/utils/helpers/criteria.ts new file mode 100644 index 00000000..140cfb8c --- /dev/null +++ b/api/src/utils/helpers/criteria.ts @@ -0,0 +1,19 @@ +/* + * Copyright © 2025 Hexastack. All rights reserved. + * + * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: + * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. + * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). + */ + +import { FilterQuery } from 'mongoose'; + +export const getCriteriaIds = ( + criteria: FilterQuery, +) => { + return Array.isArray(criteria._id.$in) + ? criteria._id.$in + : Array.isArray(criteria._id) + ? criteria._id + : [criteria._id]; +};