Updated 'count' method in rethinkdb to allow for a function input