Hi,
one possible and rather generic solution is to run the actual query in a
subquery, calculate its number of rows and then return each row from it
augmented with rowspan and colspan.
Example:
/* this is a template for an empty row */
/* it needs to contain all the attributes to be returned from the actual
query, plus default values should an attribute not be present */
LET empty = { _id: null, _key: null, name: null }
LET keepColumns = ATTRIBUTES(empty)
LET colspan = LENGTH(keepColumns) + 3 /* LENGTH([ "row", "colspan",
"rowspan" ]) == 3 */
LET result = (
/* actual query goes here, e.g. FOR doc IN collection RETURN doc */
)
LET rowspan = LENGTH(result) /* number of rows in result */
/* iterate over result and emit it */
FOR i IN 1..rowspan LET row = result[i - 1]
RETURN MERGE(empty, KEEP(row, keepColumns), { row: i, rowspan, colspan })
Best regards
Jan
Am Donnerstag, 16. März 2017 04:11:53 UTC+1 schrieb Frank Russell:
>
> I want to save html table header as graph. My question is
>
>
> 1. Is it possible to calculate rowspan and colspan using only AQL? For
> example, using edge attribute.
> 2. How to do numbering for final result? For example, {"index": i + 1}
>
>
> Attachment:
>
> - result.json : The final result json should look like.
> - columns.json: All columns (Nodes)
> - table1-columns.json: Table1 columns (Edges)
>
>
> table1:
> Graph({edges: "table1-columns", fromCollections: "columns", toCollections:
> "columns"})
>
>
>
> My pseudo query:
> LET index = 0
> FOR v,e,p IN 1..10 OUTBOUND "columns/0"
> GRAPH "table1"
> /* FILTER p.vertices[2].id != 2 */
> index = index + 1
> SORT LENGTH(p.vertices)-1,v.id
> RETURN {
> "index": index,
> "id": v.id,
> "title": v.title,
> "row": LENGTH(p.vertices)-1,
> "root": p.vertices[1].id,
> "rowspan": rowspan,
> "colspan": colspan
> }
>
>
>
> Thank you
>
--
You received this message because you are subscribed to the Google Groups
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.