How to use [object object] in an Sql query from a component

I use a select component with some values. When something is selected, by using myselect.selectedItem will give me the Json output: {"planid":2, "planname": "family"}
I'm directly using this in my sql query as below.

UPDATE mytable SET 
name = '{{new_name.value}}', 
plan='{{myselect.selectedItem}}',
WHERE ID = 1

Here, when i hover over the sql query, its;

"UPDATE mytable SET 
name = 'Cassandra', 
plan='[object Object]',
WHERE ID = 1"

Here, plan field is of type Json in the database (Postgres)
This now complains that: invalid input syntax for type json .

Whats the fix here?
Thanks!

I think this calls for

{{formatDataAsObject(myselect.selectedItem)}}...

ETA: Except I am wrong. this would be a {{JSON.stringify(myselect.selectItem)}}

1 Like

You're not wrong. It is JSON.stringify which i knew would be the case. But let me know if there are better way of doing the same