code: def add_relation(app_f, app_t, weight=1):
          '''
          Adding relation between two posts.
          '''
          recs = TabRel.select().where(
              (TabRel.post_f_id == app_f) & (TabRel.post_t_id == app_t)
          )
          if recs.count() > 1:
              for record in recs:
                  MRelation.delete(record.uid)
  
          if recs.count() == 0:
              uid = tools.get_uuid()
              entry = TabRel.create(
                  uid=uid,
                  post_f_id=app_f,
                  post_t_id=app_t,
                  count=1,
              )
              return entry.uid
          elif recs.count() == 1:
              MRelation.update_relation(app_f, app_t, weight)
          else:
              return Falsf add_relation(app_f, app_t, weight=1):
          '''
          Adding relation between two posts.
          '''
          recs = TabRel.select().where(
              (TabRel.post_f_id == app_f) & (TabRel.post_t_id == app_t)
          )
          if recs.count() > 1:
              for record in recs:
                  MRelation.delete(record.uid)
  
          if recs.count() == 0:
              uid = tools.get_uuid()
              entry = TabRel.create(
                  uid=uid,
                  post_f_id=app_f,
                  post_t_id=app_t,
                  count=1,
              )
              return entry.uid
          elif recs.count() == 1:
              MRelation.update_relation(app_f, app_t, weight)
          else:
              return False
docs: Adding relation between two posts.