Answer by vsr for Filter documents using n1ql
If You need Album document use the following query.SELECT singer, MAX([a.creationDate, a])[1] latestAlbumFROM default aWHERE a.author IS NOT MISSINGGROUP by a.authorLETTING singer = (SELECT RAW s.name...
View ArticleAnswer by EA0906 for Filter documents using n1ql
I also figured out an option to get the latest album:SELECT singer.name as singertName, ARRAY_REVERSE(ARRAY_SORT(array_agg(album.creationDate)))[0] as album from bucketwhere type='album' and...
View ArticleAnswer by Prasad Varakur for Filter documents using n1ql
Ofcourse it is possible.. Try this query:SELECT singer, FIRST x.name FOR x IN ARRAY_AGG({a.creationDate, a.name}) WHEN x.creationDate = max(a.creationDate) END AS latestAlbumFROM default aWHERE...
View ArticleFilter documents using n1ql
I have two types of documents with a relation one to many and I need to get only one document basing on the latest date value. Here it is an example:Document Type...
View Article