Reputation: 121
in parse documentation there is something about increment
parse server increment reference code
i need to achieve a decrement function to decrease the parse column by 1 each time this function is called but i can not find it in the documentation
here is my code
// we will decerment unread count
const ConversationObject = Parse.Object.extend("conversations");
var fromconvQuery = new Parse.Query(ConversationObject);
fromconvQuery.equalTo("from", this.currentUser);
fromconvQuery.equalTo("to", this.to);
var toconvQuery = new Parse.Query(ConversationObject);
toconvQuery.equalTo("from", this.to);
toconvQuery.equalTo("to", this.currentUser);
var mainconvQuery = Parse.Query.or(fromconvQuery, toconvQuery);
mainconvQuery.first({
success: function(conv){
conv.decrement('unreadCount')
conv.save()
}
})
Upvotes: 0
Views: 716
Reputation: 2906
All you need to do is specify a negative amount:
conv.increment('unreadCount', -1);
conv.save();
Upvotes: 4