Hi,
What you wanted to do
I want to write a json object to dgraph that looks like the following. I do this using the python example provided in github.
{
"model": "334_sfds",
"deviceType": "accelerometer",
"deviceDescription": "3 axis accelerometer",
"properties": [
{
"manufacturer": "siemens",
"installDate": "12/02/2021",
"wifiPass": "dafdfd"
}],
"configuration": [
{
"dataRate0": ["ODR0", 0],
"dataRate1": ["ODR1", 0],
"dataRate2": ["ODR2", 0],
"dataRate3": ["ODR3", 0]
}]
}
What you actually did
Modifying the create_data function so that it looks like the following successfully writes to dgraph - I can query the model name.
def create_data(client):
# Create a new transaction.
txn = client.txn()
try:
# Create data.
p = {
"model": "334_sfds",
"deviceType": "accelerometer",
"deviceDescription": "3 axis accelerometer",
"properties": [
{........
The actual json I’m writing has 50 configuration entries so I don’t want to manually specify the predicates I want. This led me to expand(all). I type these queries into Ratel - Query tab.
{
q(func: has(model)){
deviceType
expand(_all_)
}
}
This only returns the deviceType which is not actually what I want. It is just there to make sure the json was written into the db.
Why that wasn’t great, with examples
The few resources I’ve found seem to indicate that it’s an issue with using DQL vs graphql but I have not confirmed this.
Looking at the tutorial the following code can be found:
{
expand(func: allofterms(name, "Ivy")) {
expand(_all_) {
expand(_all_) {
expand(_all_)
}
}
}
}
Which I modify to allofterms(model, “334_sfds”)… but it still does not return any other predicates.
I have watched the full youtube series from dgraph and I have not been able to find a solution.