Remove Item From DataBase


  1. I try to remove item from database by click on button and refresh the page.
    But the product is still there.
    Someone can open my eyes to a solution?
import wixData from 'wix-data';
import wixLocation from 'wix-location';

$w.onReady( function () {
 //TODO: write your page related code here...
      $w("#datasetCompare").onReady( () => {

$w("#removeProduct").onClick( (event) => {
 let $item = $;
 let clickedItemData = $item("#datasetCompare").getCurrentItem();

     wixData.remove('Compare', clickedItemData)
      .then( (results) => {
         let item = results; //see item below
          } )
      .catch( (err) => {
         let errorMsg = err;
        } );"");
   } );

2. I want to limit the amount of products that can add to a compare database, that is possible?

Have you checked Data Collection Permissions so that Remove / Delete is set to be allowed by your members or visitors (anyone) on that Data Collection? Usually the most common error.

To limit the number of products in the Compare Data Collection you will have to query how many the user have before inserting a new one and tell them if results.totalCount === 4 they can’t add one more until they have removed one first

Can it be without logging on to the site as a user, and every time the site detects that it is a new user from new IP, then its database will be empty?

Thanks the limit is Set!!!

@topink-webmaster Working with IP is not that good because a lot of company routers and so will let all people behind the same router surf the web with the same IP Address as their public IP. If you don’t want people to have to login and register I would create some kind of session based token and store that using the Session Storage and session.setItem(“userKey”, “kjhkjhkjhkh76t76565”) something like that and then when a user hits your pages query data collection using that session token and if the session token is empty they will see no records in it because there is no records inserted with their new session token.

@andreas-kviby ok you can tell me how I make it happend

@topink-webmaster I have the same issue - any solution why it would not remove?