Hello experts,
I have a custom user signup form with userid, firstname, lastname, email and phone no. the database collection contains an additional boolean field which should be updated based on user input.
My query is
I want to update the status field based on userid. how to do this???
Please help
Thanks in advance
Hi,
You can use the query function to get the record based on the userid and use the update function to update the record.
Here's a code snippet to better explain what I'm referring:
async function updateCollectionRecord(recordId) { let recordToUpdate = await wixData.query("collectionName") .eq("_id", recordId) .find() .then(results => results.items[0]); recordToUpdate.fieldName = "ValueToUpdate"; wixData.update("collectionName", recordToUpdate) .catch((err) => { console.log(err); }); }
Good luck,
Tal.