if tx == nil {
        tx, err = db.db.BeginTx(context.Background(), &sql.TxOptions{})
        if err != nil {
            return err
        }