<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def by_id(cls, oid):
 """Find a model object by its ``ObjectId``, ``oid`` can be string or ObjectId"""

        if oid:
            d = cls.collection.find_one(ObjectId(oid))
            if d:
                return cls(**d)