knadh / localStorageDB

A simple database layer for localStorage and sessionStorage for creating structured data in the form of databases and tables
http://nadh.in/code/localstoragedb
814 stars 128 forks source link

How can I delete that data when a value is zero? #92

Closed oxcakmak closed 3 years ago

oxcakmak commented 3 years ago

For example, there is product data (id, image, title, quantity and price).

How can I delete this product when the quantity is 0?

knadh commented 3 years ago

This should work: lib.deleteRows("products", {quantity: 0});

oxcakmak commented 3 years ago

thanks for the answer. I want to do it in the if query in the basket operation I want to do, if it is not 0, it will be decreasing, if 0, it will be deleted.

` $(".minusItem").click(function(e){

e.preventDefault();

lib.update("product",{slug: $(this).attr("slug")},

    function(row) { // update function

        row.amount-=1;

        return row;

        xs=1;

    }

);

lib.commit();

shortToast("'.$lang['message_cart_minus_product'].'", "'.$lang['label_mt_success'].'", "success");

setInterval(function(){ location.reload(); },1500);

});

`