I use Knex.js to communicate to Postgres database.
I have rows in a table with a column named 'state' which represents a US state.
How can I retrieve all unique values from this column?
You are probably looking for knex.distinct + knex.pluck combo.
knex
.distinct()
.from('tablename')
.pluck('state')
.then(states => {
console.log(states)
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With