Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
each(me => {
while (!(last(cur).depth < me.depth)) cur.pop();
const left = last(cur);
if (me.rel_type == '-') {
me.left_key = me.left_key || (me.is_poly ? 'id' : singular(me.table) + '_id');
me.key = me.key || (me.is_poly ? 'attached_id' : 'id');
left.left_joins.push(me);
} else {
me.left_key = me.left_key || 'id';
me.key = me.key || (me.is_poly ? 'attached_id' : singular(left.table) + '_id');
}
left.rels.push(me);
me.poly_type = me.is_poly ?
SQL `AND ${EQ(
is_string(me.poly_type) ? { attached_type: me.poly_type || left.table } : me.poly_type
)}` : tag();
cur.push(me);
each(me => {
while (!(last(cur).depth < me.depth)) cur.pop();
const left = last(cur);
if (me.rel_type == '-') {
me.left_key = me.left_key || (me.is_poly ? 'id' : singular(me.table) + '_id');
me.key = me.key || (me.is_poly ? 'attached_id' : 'id');
left.left_joins.push(me);
} else {
me.left_key = me.left_key || 'id';
me.key = me.key || (me.is_poly ? 'attached_id' : singular(left.table) + '_id');
}
left.rels.push(me);
me.poly_type = me.is_poly ?
SQL `AND ${EQ(
is_string(me.poly_type) ? { attached_type: me.poly_type || left.table } : me.poly_type
)}` : tag();