We’re overhauling Dgraph’s docs to make them clearer and more approachable. If
you notice any issues during this transition or have suggestions, please
let us know.
Specifying node UIDs
For example, if you run this mutation:dg.3162278161.22055
during the transaction. And the final UID value
for this node is 0xfffd8d72745f0650
.
You can control the identifier name by specifying a uid
field in your JSON
data and using the notation: "uid" : "_:<your-identifier>"
In this mutation, there are two JSON objects and because they refer to the same
identifier, Dgraph creates only one node:
diggy
identifier:
species
field is added to the node already created with name
and dgraph.type
information.
Referencing existing nodes
You can use the"uid"
field to reference an existing node. To do so, you must
specify the UID value of the node.
For example:
species
information to the node that was created earlier.
Language support
To set a string value for a specific language, append the language tag to the field name. In case,species
predicate has the @lang directive, the JSON
mutation
species
string predicate in English and in French.
Geolocation support
Geo-location data must be specified using keystype
and coordinates
in the
JSON document. The supported types are Point
, Polygon
, or MultiPolygon
.
Relationships
Relationships are simply created from the nested structure of JSON. For example:food
predicate as a
relationship.
Deleting literal values
To delete node predicates, specify the UID of the node you are changing and setthe predicates to delete to the JSON value
null
.
For example, to remove the predicate name
from node 0xfffd8d72745f0691
:
Deleting relationship
A relationship can be defined with a cardinality of 1 or many (list). Setting a relationship tonull
removes all the relationships.
food
relationship.
To delete all predicates of a given node:
- make sure the node has a
dgraph.type
predicate - the type is defined in the Dgraph types schema
- run a delete mutation specifying only the UID field
Handling arrays
To create a predicate as a list of string:0x06
is the UID of the node created.
To remove one value from the list:
Adding facets
Facets can be created by using the|
character to separate the predicate and
facet key in a JSON object field name. This is the same encoding schema used to
show facets in query results. E.g.
YYYY
, MM-YYYY
,
DD-MM-YYYY
, RFC339, etc.) and as a double-quoted string otherwise. If you do
not want to risk the chance of your facet data being misinterpreted as a time
value, it’s best to store numeric data as either an int or a float.
Deleting facets
To delete aFacet
, overwrite it. When you run a mutation for the same entity
without a Facet
, the existing Facet
is deleted automatically.
Facets in list
Schema:Reserved values
The string valuesuid(...)
, val(...)
aren’t accepted.