15 lines
454 B
TypeScript
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;
|
|
};
|