DISTINCT and Unique column with strapi


It is possible to do SELECT DISTINCT column FROM table with strapi ?

Thanks !

System Information
  • Strapi Version: 4.0
  • Database: sqlite

Seems like noone knows how to do that. I am shocked that such a basic function is absent in Strapi

A much needed feature which isn’t still there in Strapi latest version too.

Have you tried await strapi.db.connection.raw( 'SQL goes here' )?

Easy achievable =) Here’s an example, where you have a table races taking place in different regions. Now you want to retrieve all possible regions within the races table. So you need distinctOn() function.
You can find further documentation on KnexJs website: Knex Query Builder | Knex.js

KnexJs tells us, that this is a Postgres only feature.

const regions = await strapi.db.connection