code: 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()),
              f 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()),
              )
docs: Add the collection or update.