Postgres Insert Into Array Javascript Iterations In Maths