<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ids(cls, filter=None, **kwargs):
 """Return a list of Ids for documents matching the filter"""

        from mongoframes.queries import Condition, Group, to_refs

        # Find the documents
        if isinstance(filter, (Condition, Group)):
            filter = filter.to_dict()

        documents = cls.get_collection().find(
            to_refs(filter),
            projection={'_id': True},
            **kwargs
            )

        return [d['_id'] for d in list(documents)]