I want to take total collection items in monaca backend

Asked 2 years ago, Updated 2 years ago, 81 views

I'm creating a simple counter app, and I'd like to aggregate who counted up how many times per user.

Is it possible to do something like count(id) in SQL?

monaca

2022-09-30 20:36

1 Answers

How about the code below?

"·The name of the collection is tentatively placed as ""counters."""
"·The target of acquisition is the ""count"" field."
"·Only items with the ""count"" field 1 are retrieved, and the total is obtained by ""totalItems""."

var counters=monaca.cloud.Collection("counters");
counters.findMine('count==1', '' , {propertyNames:["count"]})
.done(function(result)
{
   console.log('Total items found:'+result.totalItems);
})
.fail(function(err)
{
  console.log("Err#"+err.code+":"+err.message);
});


2022-09-30 20:36

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.