def search_coworkers_db(term, db):
    """
    Searches the coworkers database.

    :param term: Search term for the database.
    :type term: str

    :param db: The database object containing the coworkers database.
    :type db: `tinydb.TinyDB` object.

    :returns: `filtered_coworkers` or `all_coworkers`, an iterable of
              dictionaries, in which each dictionary is one entry in the
              database.
    :rtype: `iterable(dict)`
    """
    filtered_coworkers = list()
    all_coworkers = db.all()
    if term:
        for coworker in all_coworkers:
            for k, v in coworker.items():
                # print(k, v)
                if k == "service":
                    for srvc in v:
                        if (
                            srvc
                            and term in srvc
                            and coworker not in filtered_coworkers
                        ):
                            filtered_coworkers.append(coworker)
                else:
                    if (
                        v
                        and hasattr(v, "__iter__")
                        and term in v
                        and coworker not in filtered_coworkers
                    ):
                        filtered_coworkers.append(coworker)
        return filtered_coworkers
    else:
        return all_coworkers