Postgresql Find Element In Array Javascript Length Function In R