I’m working with Redisgraph.
I have a node Person with three properties: name (string), age (number), isAlive (boolean).
If I store the age as number, without the quotes, it correctly store it as a number. So, if I query:
MATCH (p:Person) RETURN p
what I have is:
{ name: 'John', age: 30, isAlive: 'true' }
but there’s a way to query and get real booleans?
What I want is:
{ name: 'John', age: 30, isAlive: true }
Thank you!
2
Answers
It sounds like you’re querying RedisGraph using
redis-cli
. The RESP protocol that processes module replies only allows strings and integers as primitive data types that can be passed, so your request can’t be accomplished throughredis-cli
.All of the client libraries, however, will decode replies to their correct type. I’d recommend using one as an intermediary to interact with RedisGraph – https://oss.redis.com/redisgraph/clients/.
Redisgraph can return a compact format where the type of the values are included. In order to use this you need to pass the
--compact
flag (which also works in redis-cli):Some client libraries takes advantage of this compact format in order to return the correct type. The type of value is returned as an integer:
You can read more about the compact format here.