Here we create a subscription on Orders collection, which returns the orders and brings along all products mentioned in the order as included documents.
See the usage example here.
Include statements supported only with raw RQL. Include statements come in two forms, like in any other RQL statements:
1. Include statement in the end of the query, starting with the
include keyword, followed by paths to the field containing the ids of the documents to include.
If projection is performed, the mechanism will look for the paths in the projected result, rather then the original document.
It is recommended to prefer this approach when possible both because of clarity of the query and slightly better performance.
2. Include function call inside a 'declared' function.
Query = @"from Orders include Lines.Product"
Query = @"
declare function includeProducts(doc)
doc.LinesCount = doc.Lines.length;
for (let i=0; i< doc.Lines.length; i++)
from Orders as o select includeProducts(o)"