Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (items instanceof Array && items.length < 1) {
// it's only possible to update items with one ore more refs. Early exit
return;
}
if (items && record) {
const models: Model|Array|IIdentifier|undefined|null = mapItems(
items,
(def: IDefinition) => this.find(def.type, def.id) || def.id,
);
const itemType: string = items instanceof Array ? items[0].type : items.type;
if (ref in record) {
record[ref] = models;
} else {
// @ts-ignore - Ignore until datx is updated
initModelRef(record, ref, {model: itemType, type: ReferenceType.TO_ONE_OR_MANY}, models);
}
}
});
}