Wed Sep 6
- learnt about the following
dgraphmutationtoday.
mutation {
set {
_:cat <name> "Millhouse" .
_:cat <color> "Black" .
_:cat <age> "0.7"^^<xs:float> .
_:human <name> "Kaley" .
_:human <age> "22"^^<xs:float> .
_:human <favorite_food> "chocolate" .
_:human <owns> _:cat .
}
schema {
name: string @index .
}
}
** mutation is for changing data in the graph or changing the graph schema
** set is for mutations that insert triples into the graph
** the strange syntax ^^<xs:float> is apparently how a value is typed as a float...
-
about
dgraphtriples ** triples are specified according the W3C standard https://www.w3.org/TR/n-quads/[RDF N-Quad format] ** their format is<subject> <predicate> <object> .subjectis always a node.objectis either anodeor avalue(also know as literal).predicateis a directed edge fromsubjecttoobject, the value here is the edge name. A given edge must always point to a consistent type (in effect the edge type). A.is present because of the spec apparently less because of need on dgraph side https://dgraph.slack.com/archives/C13LH03RR/p1504754827000129[link] -
blank nodeis written_:identifierin a mutation. Used to identify a node within a mutation. Outside a particular mutation the identifiers have no existance._will be replaced by dgraph with an automatically generated 64bit unique ID. These IDs are available in the mutation return result:
{
"data": {
"code": "Success",
"message": "Done",
"uids": {
"foo": "0x2712",
"qux": "0x2713",
"bar": "0x2714"
}
}
}
-
links: https://docs.dgraph.io/query-language/#mutations[mutation docs], https://docs.dgraph.io/master/guides/#adding-data-to-dgraph[guide/intro to mutations]
-
in
dgraphschema types are defined globally without any ability to nest into records. https://dgraph.slack.com/archives/C13LH03RR/p1504755357000113[link]. For example this would fail:
mutation {
schema {
foo {
bar: string .
}
}
}
but this would work:
mutation {
schema {
bar: string .
}
}
dgraphsupports pagination which can be used as the basis for doing batch work across an entire graph. slack link, pagination docs link