I have a class like this:
class Foo {
static hasMany = [bars: Bar]
}
When I write:
Foo.getAll()
I get a list of Foo
objects like this:
[ Foo1, Foo2, Foo3 ]
When I write:
Foo.getAll().bars
I get a list of lists of Bar
object like this:
[ [ Bar1, Bar2 ], [ Bar2, Bar3 ], [ Bar1, Bar4 ] ]
But what I want is a unique list of Bar
objects like this:
[ Bar1, Bar2, Bar3, Bar4 ]
My end goal is to have a unique list of ids of the Bar
object in the list above, like this:
[ 1, 2, 3, 4 ]
I have tried variations of the collect method and I have also tried the spread operator but I'm not having any luck.