UNPKG

lux-framework

Version:

Build scalable, Node.js-powered REST APIs with almost no code.

24 lines (20 loc) 467 B
// @flow import type { Model } from '../../index'; // eslint-disable-line no-unused-vars /** * @private */ function unassociateOne<T: void | ?Model>(value: T, foreignKey: string): T { if (value) { Reflect.set(value, foreignKey, null); } return value; } /** * @private */ export default function unassociate<T: Model, U: Array<T>>( value: U, foreignKey: string ): U | Array<T> { return value.map(record => unassociateOne(record, foreignKey)); }