Hi,
maybe i explained wrong.
I’d like to retrive the document AND it’s id, so using
SELECT MIN([t.date, t])[1]...
i select only the document, and with
SELECT MIN([t.date, META(t).id)])[1]...
i select only the id.
The only way i found work is:
SELECT MIN([t.date.date, t, t])[1], MIN([t.date.date, t, META(t).id])[2] ...
but i was wondering if it was the right way.
Also, in the case of two document with the same lowest date, i’d like to get if exists the one with the field is_outward
true. In case there is no document with is_outward
true, the query should fallback to the doc with is_outward
false.
So, if i have these 3 docs:
{
"date": "2018-05-30",
"is_outward": true,
"group_id": 1,
"_id": 1
}
{
"date": "2018-05-30",
"is_outward": false,
"group_id": 1,
"_id": 2
}
{
"date": "2018-06-01",
"is_outward": true,
"group_id": 1,
"_id": 3
}
the query should return the document with id = 1.
If the first document would not exist, return the document with id = 2.
Thanks in advance and sorry for not be explicit in the previous questions.