Hi, I'm trying to update the column column ethBal...
# help
k
Hi, I'm trying to update the column column ethBalance in a row with the ethAddress passed in the function but i keep getting ".update is not a function"
Copy code
js
export const updateEthBalance = async (ethAddress, ethBalance) => {
  const { data, error } = await supabase.from('users').select().eq('ethAddress', ethAddress).update({ ethBalance: ethBalance })
  console.log(data);
};
Am I doing it wrong?
n
Hello @kingpeppe! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
k
i'm able to grab the right row by
Copy code
js
const { data, error } = await supabase.from('users').select().match('ethAddress', ethAddress)
but i can't get update to work
I've tried many combinations.
Copy code
js
const { data, error } = await supabase.from('users').select().match({ ethAddress: ethAddress }).update({ ethBalance: ethBalance });
This one looks like it should work, but it doesn't
t
From https://supabase.com/docs/reference/javascript/update I think it will be closer to
Copy code
js
const { data, error } = await supabase.from('users').update({ ethBalance: ethBalance }).match({ ethAddress: ethAddress });
n
kingpeppe (2022-04-12)
t
so no need for the
select()
And move the
update
you had to replace where you had
select()
k
That did it. Thank you so much!
t
no worries. Glad I could help.
k
It's right there in the doc. I'm such a dummy.
I've read through it a few times and tried every combination but what you sent me
t
haha. I'm terrible at reading and debugging my own code. I'm better at looking at others 🙂 Its a good skill.
k
i was sure i needed to select the entire row
Thanks again