'Get the total number of available records in this resource
@param left: left outer joins, if required
@param distinct: only count distinct rows'

def count(self, left=None, distinct=False):

    if (self.rfilter is None):
        self.build_query()
    if (self._length is None):
        self._length = self.rfilter.count(left=left, distinct=distinct)
    return self._length
