'Filters (if `neg` == True, filters out) one particular category
(records may have zero, one or more categories).'

@staticmethod
def searchcategory(cat, neg=False):

    if neg:
        if isinstance(cat, utils.REGEXP_T):
            return {'categories': {'$not': cat}}
        if isinstance(cat, list):
            if (len(cat) == 1):
                cat = cat[0]
            else:
                return {'categories': {'$nin': cat}}
        return {'categories': {'$ne': cat}}
    if isinstance(cat, list):
        if (len(cat) == 1):
            cat = cat[0]
        else:
            return {'categories': {'$in': cat}}
    return {'categories': cat}
