I have two collections, cars
and car_colors
, where a "car" hasA "color":
// Groovy pseudo-code
@Entity
class Car extends AbstractMongoEntity {
String make
String model
CarColor color
}
@Entity
class CarColor extends AbstractMongoEntity {
String name // e.g. "Red"
String label // e.g. "RED"
String description // e.g. "The color red."
}
I am using Morphia 1.0.1 to OR/map between these POJO entities and MongoDB data. I am looking for a query/selector/find that will allow me to lookup all the Cars
with a CarColor#label
of, say, 'BLUE'
. I believe this involves a JOIN operation somehow, though I'm not seeing how. Here's my best attempt so far which doesn't work:
datastore.find(Car).field('color').field('label').equal('BLUE').asList()
Any ideas?