backend/lib/seed/helpers/Utils.checks.ts
2025-05-14 21:45:16 +02:00

15 lines
454 B
TypeScript

import _ from 'lodash';
import { newError } from './Error';
export const isAllThere = (listIds: string[], data: any[], modelName = 'modelName'): void => {
const ids = _.map(data, '_id');
const nIds = _.difference(listIds, ids);
if (nIds.length > 0) throw newError(4041, { id: nIds.join(','), model: modelName });
return;
};
export const hasDuplicates = (array: any[]): boolean => {
return _.uniq(array).length !== array.length;
};