How to truncate a foreign key constrained table in mysql?

You cannot TRUNCATE a table that has FK constraints applied on it (TRUNCATE is not the same as DELETE). To work around this, use either of these solutions. Both present risks of damaging the data integrity. Option 1: Remove constraints Perform TRUNCATE Delete manually the rows that now have references to nowhere Create constraints Option … Continue reading How to truncate a foreign key constrained table in mysql?

Array Stuffs – Vanilla JavaScript & ES6+

Find object by id in an array of JavaScript objects: myArray = [{‘id’:’73’,’foo’:’bar’},{‘id’:’45’,’foo’:’bar’}, etc.] let array2 = myArray.map(item => item.id); // assign objects to an array from 2 diff arrays: array1 = [{id: 1, name: ‘nnn’}, {id:2, name: ‘jjjj’}]; array2 = [{id: 2, name: ‘nnn’}, {id:3, name: ‘jjjj’}]; array1.forEach(e1 => array2.forEach(e2 => { if (e1.id … Continue reading Array Stuffs – Vanilla JavaScript & ES6+