Hi,
Totally straight forward question. Want to drop all the mutations present in the graph. what I found on the dgraph tour
that we can drop data by id
but can we drop database by its name or drop all the mutation.
Thank you
Hi,
Totally straight forward question. Want to drop all the mutations present in the graph. what I found on the dgraph tour
that we can drop data by id
but can we drop database by its name or drop all the mutation.
Thank you
DELETE ALL DATA: https://docs.dgraph.io/deploy/#delete-database
To drop all data, you can use :
{
"drop_all": true
}
It deletes everything from the database and starts from a clean state.
Hi @karan28aug
tried with this but getting an error Expected Left round brackets. Got: lex.Item [14] ":"
I tried this again it is working without an error.
Just try it again in Alter in Ratel and let me know if it works for you or again showing you the same error.
you should run this operation in alter not in query or others like mutate, schema.
curl -X POST localhost:8080/alter -d ‘{“drop_all”: true}’
can you tell one more thing
how can i fetch whole data with one query withput using any id
sample - In sql we use * from fetching all the data
{
all_nodes(func: has(_predicate_)) {
expand(_all_) {
expand(_all_)
}
}
}
Try to use this and let me know if it works for you
yaa ts working
Is there anything like nodetype
in dgraph or if its there how will i know.
thank you
You can set a type to the Node when you are setting a schema for the data to be loaded.
For ex:
name: string @index(term) @lang .
age: int @index(int) .
friend: uid @count .
Here string, int, uid are type you have assigned to name, age and friend…
I think you miss understood something, let me clear more
actually, i played with NEO4J sometimes back, in NEO4J we have to make a nodetype
first to insert data.
NEO4J query : CREATE (n:People{name:"abc", age:35})
People is a nodetype
Similarly, how can i create nodetype in dgraph
Ref: howto
import pydgraph
import json
client_stub = pydgraph.DgraphClientStub('localhost:9080')
client = pydgraph.DgraphClient(client_stub)
# Create Schema
schema = """type: string @index(exact) .
name: string ."""
op = pydgraph.Operation(schema=schema)
client.alter(op)
# Data
txn = client.txn()
p = {
"type": "People",
"name": "Alpha",
}
assigned = txn.mutate(set_obj=p)
q = {
"type": "People",
"name": "Beta",
}
assigned = txn.mutate(set_obj=q)
txn.commit()
# Fetch type people
# Fetch Data
query = """query all($a: string) {
all(func: eq(type, $a)) {
expand(_all_) {}
}
}"""
variables = {'$a': 'People'}
# Print
res = client.query(query, variables=variables)
ppls = json.loads(res.json.decode('utf-8'))
for ppl in ppls["all"]:
print(ppl)
I think its a hack to get node type, but it seems to wrok
great
can we explicitly declare nodetype
.
something like this
I have a similar post here Have many `schema`s
type School struct {
Name string `json:"name,omitempty"`
}
type Person struct {
Uid string `json:"uid,omitempty"`
Name string `json:"name,omitempty"`
Age int `json:"age,omitempty"`
Married bool `json:"married,omitempty"`
Raw []byte `json:"raw_bytes,omitempty"`
Friends []Person `json:"friend,omitempty"`
School []School `json:"school,omitempty"`
}
You can do something like this.
Hi @karan28aug
like below format, I am creating a schema in python. Can you tell me how may I use above schema in python.
name: string @index(exact) .
friend: uid @reverse .
age: int .
married: bool .
loc: geo .
dob: datetime .