Postgres Select Item In Array Javascript Function Definition