ViewFoundSet Total Size

What is the best way to get the total size of a ViewFoundSet?

databaseManager.getFoundSetCount() doesn’t support ViewFoundSet.
ViewFoundSet.getSize()will only return a maximum of 200.

I devised a generic method as follows. Is there a better way?

/**
 * @param {ViewFoundSet} _vfs
 * @return {Number}
 * @public 
 */
function getViewFoundSetCount(_vfs) {
	const _query = _vfs.getQuery();
	
	_query.result.clear().add(_query.aggregates.count());
	
	const _ds = databaseManager.getDataSetByQuery(_query, 1);
	
	return _ds.getMaxRowIndex() ? _ds.getRowAsArray(1)[0] : 0;
}

1 Like

Hi Seain,

Servoy currently doesn’t support databaseManager.getFoundSetCount() for view foundsets.
It would be a good addition , please create a feature request on support.servoy.com.

You method to get the count does about what happens internally in Servoy, it looks good as a workaround.

Rob

1 Like