Postgresql Find Element In Array Javascript Append To List