Skip to content

Commit a010686

Browse files
committed
Update the command line server documentation
1 parent a6d888d commit a010686

2 files changed

Lines changed: 137 additions & 3 deletions

File tree

bql/table/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ func (t *Table) ToJSON(w io.Writer) {
831831
w.Write([]byte(strings.Replace(c.L.String(), `"`, `\"`, -1)))
832832

833833
} else if c.T != nil {
834-
w.Write([]byte(`node": "`))
834+
w.Write([]byte(`anchor": "`))
835835
w.Write([]byte(strings.Replace(c.T.Format(time.RFC3339Nano), `"`, `\"`, -1)))
836836
}
837837

docs/command_line_tool.md

Lines changed: 136 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,139 @@ and array of results. Each element of the array contains:
396396
* _query_: The original passed query.
397397
* _msg_: A human readable message. It will contain error information if the
398398
query failed to execute correctly.
399-
* _table_: It the query was a query result, table will contain the obtained
400-
result.
399+
* _table_: If the query was run successfully and a query result was produced,
400+
_table_ will contain an array with the output bidings under
401+
_bindings_. The table data will be provided as an array of rows
402+
under the _rows_ field. Each row entry represents an object where
403+
the fields are the binding name and the valu an object containing
404+
the cell value. The cell value is an object that may contain
405+
one of the following fields depending on the value type:
406+
_string_, _node_, _pred_, _lit_, or _anchor_. All the values
407+
are represented using the string format for each time. Time
408+
anchors are formated following
409+
(RFC3339Nano)[https://godoc.org/time#pkg-constants].
410+
411+
For instance you can pass the following queries to the endpoint
412+
413+
```
414+
create graph ?test;
415+
416+
insert data into ?test {
417+
/foo<id> "knows"@[] /bar<id>.
418+
/foo<id> "follows"@[] /bar<id>
419+
};
420+
421+
select ?s,?p,?o,?k,?l,?m
422+
from ?test
423+
where {
424+
?s ?p ?o.
425+
?k ?l ?m
426+
};
427+
```
428+
429+
The endpoint will execute each of the statements in order and return and array
430+
of JSON formated objects, one for each query. For the above example you should
431+
get the following JSON on a newly started server:
432+
433+
```
434+
[{
435+
"query": "create graph ?test;",
436+
"msg": "[OK]",
437+
"table": {
438+
"bindings": [],
439+
"rows": []
440+
}
441+
}, {
442+
"query": "insert data into ?test { /foo<id> \"knows\"@[] /bar<id>. /foo<id> \"follows\"@[] /bar<id> };",
443+
"msg": "[OK]",
444+
"table": {
445+
"bindings": [],
446+
"rows": []
447+
}
448+
}, {
449+
"query": "select ?s,?p,?o,?k,?l,?m from ?test where { ?s ?p ?o. ?k ?l ?m };",
450+
"msg": "[OK]",
451+
"table": {
452+
"bindings": ["?s", "?p", "?o", "?k", "?l", "?m"],
453+
"rows": [{
454+
"?s": {
455+
"node": "/foo<id>"
456+
},
457+
"?p": {
458+
"pred": "\"knows\"@[]"
459+
},
460+
"?o": {
461+
"node": "/bar<id>"
462+
},
463+
"?k": {
464+
"node": "/foo<id>"
465+
},
466+
"?l": {
467+
"pred": "\"knows\"@[]"
468+
},
469+
"?m": {
470+
"node": "/bar<id>"
471+
}
472+
}, {
473+
"?s": {
474+
"node": "/foo<id>"
475+
},
476+
"?p": {
477+
"pred": "\"knows\"@[]"
478+
},
479+
"?o": {
480+
"node": "/bar<id>"
481+
},
482+
"?k": {
483+
"node": "/foo<id>"
484+
},
485+
"?l": {
486+
"pred": "\"follows\"@[]"
487+
},
488+
"?m": {
489+
"node": "/bar<id>"
490+
}
491+
}, {
492+
"?s": {
493+
"node": "/foo<id>"
494+
},
495+
"?p": {
496+
"pred": "\"follows\"@[]"
497+
},
498+
"?o": {
499+
"node": "/bar<id>"
500+
},
501+
"?k": {
502+
"node": "/foo<id>"
503+
},
504+
"?l": {
505+
"pred": "\"knows\"@[]"
506+
},
507+
"?m": {
508+
"node": "/bar<id>"
509+
}
510+
}, {
511+
"?s": {
512+
"node": "/foo<id>"
513+
},
514+
"?p": {
515+
"pred": "\"follows\"@[]"
516+
},
517+
"?o": {
518+
"node": "/bar<id>"
519+
},
520+
"?k": {
521+
"node": "/foo<id>"
522+
},
523+
"?l": {
524+
"pred": "\"follows\"@[]"
525+
},
526+
"?m": {
527+
"node": "/bar<id>"
528+
}
529+
}]
530+
}
531+
}]
532+
```
533+
534+
The table fi

0 commit comments

Comments
 (0)