amidknight
2 years ago

Return only unique strings

Posted 2 years ago by amidknight

Not sure if this is the right channel per se, or if this question has already been asked.

I have a schema with a field that accepts a slugged string. This schema also has a relationship id field. Therefore, the slug field does not need to be unique unless the relationship id is also the same.

| Slug  | relationship_id |
|-------|-----------------|
| Hello |        1        |
| Hello |        2        |
| Sup   |        1        |
| Hello |        3        |
| Sup   |        2        |

What I would like to do is have a query (or model request) that gets a result set containing only the unique slugs in it - regardless of the id.

Collection {
    [
        'hello', 
        'sup'
    ]
}

Is that possible; or should I be looking for something else.

Please sign in or create an account to participate in this conversation.