Count how many times clicked on button

Hello,
I need to somehow count number of clicks on one button in my application. Does somebody know how to do that? Can You explain me steps because I'm new on Appery.io?
Regards!
1 person has
this question
+1
Reply
  • Hello Leo,

    1. Please, create a database collection for that number, e.g. "myCollection"

    2. Add a column (e.g. with a name "myNumber") with a type = number in that collection

    3. Create a row in that collection and save it's ID (will be used in the next step)

    4. Create a Server Code, for that counting and click it on the click event:

    var dbId = "516fb7c3e4b040d8f16ccf9a";
    var collectionName = "myCollection";

    var result = Collection.multiUpdateObject(dbId, collectionName, '{_id: "5a453864a428937aa5fcb100"}', null,{
    "$inc": {"myNumber": 1}
    });

    Please replace dbId value to your database ID
    collection "myCollection" to your collection with the number of clicks
    and "5a453864a428937aa5fcb100" with the row Row ID from the step #3
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated indifferent, undecided, unconcerned