Hello!
How can I delete a row in a database specifically from the current user after wixData.query?
wixData.query("ReviewsPermission")
.eq("_owner", wixUsers.currentUser.id)
.find()
.then((result)=>{
let data = result.items;
let ownerID = data._owner;
// I don't know what's next...
})
I believe this is basic, but I don’t know the specific code for this.
First of all I need to have a query in ReviewsPermission database to find the row which have the current user’s _owner. Then after finding it, the code should delete that row which means to say all of the items that were inserted there will be removed or deleted. So if there is a total of 10 rows in ReviewsPermission database, after deletion, it will be 9 rows.
import wixUsers from 'wix-users';
import wixData from'wix-data';
let user = wixUsers.currentUser;
let userId = user.id;
wixData.query("ReviewsPermission")
.eq("_owner", userId)
.find()
.then((result)=>{
let ownerId = result.items[0]._owner;
})
YES! I already understand the code and it works! Thanks @ajithkrr !
This is for anyone of you who still doesn’t know how to remove a row in your database using the code below.
wixData.remove("CollectionName", _id)
The _id in that code is literally the _id in your database NOT the _owner nor any field key in your database because through the use of the _id, it can easily find which row should be deleted. So it’s up to you how you will put the specific _id in that code.