For a data service, can you get the number of records or data objects.
Hey there!
DataObjectService has 3 different methods for getting counts:
-
loadCount(DataObjectQuery)which will return a Number of DataObjects that match that query. In Java it’s a Long, and in JS/JSON it’s a Number. -
accumulate(Accumulation)which you can learn more about here, specifically can find COUNTs of any objects, and MIN, MAX, MEAN, and SUMs of numeric fields on DataObjects. This returns a Number for JS/JSON, but for Java the type of number depends on the accumulator (MEAN is a double, COUNT is a long, etc.) -
groupedAccumulate(GroupedAccumulation)which you can learn about here, specifically can do a GROUP BY and any of the accumulators I mentioned above (COUNT, MIN, etc.). So instead of getting a single number back, you get back a Map of what you grouped by to the numeric result.
Also loadCount(...) and accumulate(...) with a COUNT accumulator do the exact same thing. The latter is just a newer and more flexible API in that it supports other accumulators.
Also disclaimer that the examples for Accumulations I linked to are correct for 3.10+. Switch the LEAF version in the URL to 3.9 to see the older way to construct Accumulations, since it very recently went through a change.
Also for loadCount and data object queries, this is useful for getting code examples for Java/TS/JS for queries.