<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def add_or_update(user_id, app_id):
        '''
        Add the collection or update.
        '''

        rec = MCollect.get_by_signature(user_id, app_id)

        if rec:
            entry = TabCollect.update(
                timestamp=int(time.time())
            ).where(TabCollect.uid == rec.uid)
            entry.execute()
        else:
            TabCollect.create(
                uid=tools.get_uuid(),
                user_id=user_id,
                post_id=app_id,
                timestamp=int(time.time()),
            )