Makoto
Posts: 0
Joined: Fri Oct 10, 2014 8:15 am

How to count and return the total number of items in an array in database?

Hi, appery support team!

Is it possible to use $size (Array Aggregation Operator) in order to count and return the total number of items in an array in database? If not, is there any way to accomplish it?

I referenced to the following site.
https://docs.mongodb.org/master/refer...

Makoto
Posts: 0
Joined: Fri Oct 10, 2014 8:15 am

How to count and return the total number of items in an array in database?

Hello Sergiy,

thank you very much for your help. But, I know $size makes it possible to retrieve elements in an array.

My question is how to use $size in order to “count and return the total number of items in an array in database”.

Thank you.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to count and return the total number of items in an array in database?

Hello Makoto,

$size - standard MongoDB operator, it selects documents if the array field is a specified size.
Please find more here http://docs.mongodb.org/manual/refere...
To count total number of records you should you custom code.
This should be useful https://getsatisfaction.com/apperyio/...

Makoto
Posts: 0
Joined: Fri Oct 10, 2014 8:15 am

How to count and return the total number of items in an array in database?

Hi Alena,

thank you for your reply. And, I could understand that it is not suitable to use $size operator for counting and returning the total number of items in an array in database when using Appery. I’ll try the method that you explained above. Thanks!

Return to “Issues”