In a Flux query I was writing I wanted to negate the fetched values using a map
function to multiply each value by -1
:
map(fn: (r) => ({ _value: r._value * -1 }))
To my surprise this yielded an error:
type conflict: int != float
Took me a few Google Search Coupons to realize the error got trigger not by the type of the _value
, but by the -1
in there. The solution therefore is really simple: don’t multiply by an integer (e.g. -1
) but multiply by a float (e.g. -1.0
); like so:
map(fn: (r) => ({ _value: r._value * -1.0 }))
😅
Did this help you out? Like what you see?
Thank me with a coffee.
Thank me with a coffee.
I don't do this for profit but a small one-time donation would surely put a smile on my face. Thanks!
To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.