dgraph/standalone
docker image.dgraph/standalone
docker image is the quickest way to get started
with Dgraph. This standalone image is meant for quickstart purposes only. It is
not recommended for production environments.
Ensure that Docker is installed and running
on your machine.
Now, it’s just a matter of running the following command, and you have Dgraph up
and running.
Ann
and one holding the information about Ben
.
What we know is the name
and the age
of those persons.
We also know that Ann follows Jessica. This is also stored as a relationship
between the two nodes.
Mutate
tab and paste the following mutation into
the text area.
name
and age
with the
corresponding values.
It also creates a predicate ‘follows’ for that entity but the value isn’t a
literal (string, int, float, boolean).
So Dgraph also creates a second entity that’s the object of this predicate. This
second entity has itself some predicates (name
and age
).
Let’s execute this mutation. Click Run!
"uids"
field of the response correspond to the
two entities created for Ann and Ben.
has
function. The expression has(name)
returns all the
entities with a predicate name
associated with them.
Query
tab this time and type in the query. Then, click Run
on the
top right of the screen.
people
. However, you could use any other name.
The func
parameter has to be associated with a built-in function of Dgraph.
Dgraph offers a variety of built-in functions. The has
function is one of
them. Check out the query language guide to know more
about other built-in functions in Dgraph.
The inner fields of the query are similar to the column names in a SQL select
statement or to a GraphQL query!
You can easily specify which predicates you want to get back.
has
function to find all entities with the age
predicate.
name
,
age
, and country
, the second one has name
, age
, and city
.
Schemas aren’t needed initially. Dgraph creates new predicates as they appear in
your mutations. This flexibility can be beneficial, but if you prefer to force
your mutations to follow a given schema there are options available that we’ll
explore in the next tutorial.