Help putting multiple keys into redis

  • Goal: Trying to troubleshoot why this query isn't working

  • Steps:

HSET banned_wallets{{ 
  uploadBanned.data.reduce((acc, element) => 
    {return acc += " " + element["Wallet id"] + " '" + JSON.stringify(
      {
        "notes": notes2.value
      }
    ) + "'"}, ''
  )
}}

shows this output

"HSET banned_wallets 0x9c639158356583Ff47B256db7C4D36CdEaeD54cC '{"notes":"testv"}' 0x5345156a6f95252303FbC041f39E5F98EfBCe79B '{"notes":"testv"}' 0x34586D12B724fE523Bd34B2b98893a719b764eD8 '{"notes":"testv"}'"

which gives this error

addMultipleBanned failed (0.001s):Bad control character in string literal in JSON at position 11 (line 1 column 12)

addMultipleBanned

from addMultipleBanned response(addMultipleBanned)

:arrow_forward:in addMultipleBanned.trigger()(addMultipleBanned)

However if i paste that string directly into the command it works fine

Hi @Vinh_Trinh,

Thanks for reaching out! Just to clarify, if you copy the output of the dynamic query, and paste it into a new Retool query (in other words, if you hardcode the query), it works as expected?

If so, have you tried removing the extra quotes from the part in {{}} or moving that code to a Javascript transformer & then referencing the transformer here?

yea tried all the above. So the silly workaround was to output the data directly into another textfield (which I hid in the UI) and then import the textfield data =/

that worked

Hey @Vinh_Trinh apologies for the delay! I spun up a Redis resource to test with.

I'm running into similar issues - it's tricky to figure out the best syntax :thinking: The GUI/dropdown version of the query editor is much easier to work with as far as using dynamic values- is that an option for you?

Writing to a temporary text field and then using the temporary text field works so we are just running with that . Thanks for looking into it though

sounds good :slight_smile: