Inserting nested child list with 2 or more columns without id

hi,

is it possible to insert a predicate that contains a list of data that contains multiple column?

example:

childField: [ { field1: "aa", field2: "bbb"} ]

i do not plan to insert the child fields as individual objects,

thank you

Nops, try something similar with Facets

https://docs.dgraph.io/query-language#facets-edge-attributes

Mutation

{
		"set": [
			{
				"childField": [ 
          {"column1": "This is a column",
    			 "column1|field1": "aa",
    			 "column1|field2": "aa2" },
          {"column2": "This is a column",
    			 "column2|field1": "bb" ,
    			 "column2|field2": "bb2" }
        ]
      }
		]
}

Query


{
  data(func: has(childField)){
    uid
    childField {
    uid
    column1 @facets
    column2 @facets
    }
  }
}

Response


{
  "data": {
    "data": [
      {
        "uid": "0x2711",
        "childField": [
          {
            "uid": "0x2712",
            "column1|field1": "aa",
            "column1|field2": "aa2",
            "column1": "This is a column"
          },
          {
            "uid": "0x2713",
            "column2|field1": "bb",
            "column2|field2": "bb2",
            "column2": "This is a column"
          }
        ]
      }
    ]
  }

thank you @MichelDiz

but this is hardcoding suffix of predicate with index of rows.
i did found out that facets only support specific name of predicate.

this is the only way todo it right? otherwise ive to work with uid

Not sure what you mean :confused:

btw another example would be the one below (Facets are like “list”)


{
		"set": [
			{
				"childField": [ {"childField|field1": "aa", "childField|field2": "aa" } ]
             }
 	        	]
}

There is no other way. Dgraph only accepts the specified Data types by design. There is no concept of “column” in a graph DB and there is no way to insert JSON obj into a predicate.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.