How to clear a value on page load for derbyjs

61 Views Asked by At

Just out of curiosity if I have a chat application with an unread message counter...

How do I reset that counter?

Simply put, when User A writes a message, B increments there unread counter. When B is on the message page, I would like to reset that counter each refresh of the messages (it is running on subscribe).

Any ideas?

2

There are 2 best solutions below

0
msj121 On BEST ANSWER

Actually it was pretty simple.

You can write the following code in your html:

{{yourMethodName();}}

Then in your server you write some code:

app.proto.yourMethodName = function(){
  //Clear data
  this.model.del("yourdata.count");
  //similar to: this.model.set("yourdata.count",0);
}

Super simple.... Updated based off of Aleksey

0
Aleksey Igoshev On

or this.model.del("yourdata.count");