List of `bool `

I try to set a list of scalars of type bool as a predicate with the following schema definition:

boolValues: [bool] @index(bool) .

but I get the error

Unsupported type for list: [bool].

Dgraph version: v1.1.0

Bool has only two possible results. There’s no meaning to have a list of it.

That’s right lol!

In our case, we are using facets and, for example, two or more edges could point to the same “false” value but with different facet values.

For example, imagine I want to persist this JSON object:

    "myList": [true, true, false, true, false ]

I was thinking about using:

myList: [bool] .

_:tom <myList> "true" (index="0") .
_:tom <myList> "true" (index="1") .
_:tom <myList> "false" (index="2") .
_:tom <myList> "true" (index="3") .
_:tom <myList> "false" (index="4") .

How would you store this data in dgraph @MichelDiz? any ideas? :slight_smile:

For now this can’t be possible.

But I’m afraid it won’t work anyway (when we support list-type facets). For list does not tolerate repeated values. Equal values are considered the same as far as I know. Unless Ashish commit modifies this behavior.

What you could do is make a JSON object to String (to escape or unescape) and insert it into a String list. That way you can do what you want to do.

_:tom <myList> "{ \"index\":\"0\", \"bool\": true }" .
_:tom <myList> "{ \"index\":\"1\", \"bool\": true }" .
_:tom <myList> "{ \"index\":\"2\", \"bool\": false }" .
_:tom <myList> "{ \"index\":\"3\", \"bool\": true }" .
_:tom <myList> "{ \"index\":\"4\", \"bool\": false }" .

After we have list-type with facets support. You can use them in this same approach.

1 Like