So I'm working in Node.js and using the 'pg' npm module. I'm trying to check to see if the contents of an array are contained within an array that's stored in a Postgres table (the order doesn't matter to me--it should return true if there is a 1:1 element ration between arrays).
The Postgres query looks like this:
let getComFromMembers = `SELECT * FROM ComTable WHERE (members @> ($1) AND members <@ ($1))`
In my javascript, I'm calling it like this:
let results = await client.query(getComFromMembers, [numberMembers]);
numberMembers is an array that was originally pulled from Postgres, and then mapped to a number array:
let postgresArray = []
// query tables and populate postgresArray with .push()
let numberArray = postgresArray.map(Number)
For some reason, I'm not getting anything back from 'results'. As an example, in the case where numberArray would be an array with elements 1, 2, and 3, look below.
To get it to work I need to query directly into my database:
SELECT * FROM ComTable WHERE (members @> '{1,2,3}' AND members <@ '{1,2,3}')