I have an object that contains multiple objects, this is a simplification of the project I am try to address. The parent object has a predicate of objects stored within it. I need a list of the parent objects which either only contains objects with the desired attribute values or does not contain objects with the undesired values.
In the below example I am looking for the boxes which do not have any red devices, or the boxes which only have green devices.
The schema is
color: string .
devices: [uid] .
in_box: uid .
type device {
color
in_box
}
type box {
devices
Sample Query:
{
query(func: Type(box) {
uid
device {
uid
color
}
}
}
Returns:
{'query': [{'uid' : '0x1', 'devices': [{'uid': '0x2', 'color': 'green'}, {'uid': '0x3', 'color': 'green'}],
[{'uid' : '0x4', 'devices': [{'uid': '0x5', 'color': 'green'}, {'uid': '0x6', 'color': 'red'}],
[{'uid' : '0x7', 'devices': [{'uid': '0x8', 'color': 'red'}, {'uid': '0x9', 'color': 'green'}]]}
I would like a query that would only return the box without any ‘red’ devices, in this example, '0x1.