Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
Incrementing firebase monetary value after Paypal transaction instead of replacing value

I am trying to increment a monetary value within firebase. When a user makes a project donation by paypal, a project key variable is attached to the paypal button and then is passed along with the transaction details to firebase. Then the mc_gross value (amount donated) is added to the amountFundraised key for that specific project key. Right now it is just replacing the current value from amountFundraised with mc_gross instead of incrementing.

So if the current amountFundraised is 100 and mc_gross is 50, the value for amountFunraised will now be 150.

Does anyone have any suggestions?

I tried using the increment() function but it is not working.

import { Router } from "express";
import { database,} from "../../firebase";
import { increment } from 'firebase/database';

export const router = Router();

router.get('/', (req, res) => {
  res.send('Express + TypeScript Server');
});

router.post('/payments', (req, res) => {
  console.log(req.body);
  console.log(req.query);
  const data = {
    ...req.body,
    ...req.query,
  }

  database.ref().child('/payments').push(data);
  database.ref().child(`projects/${data.projectKey}`).update({amountFundraised : increment(Number(data.mc_gross))})

  res.json('Okay');
})

I have also tried firebase.firestore.FieldValue.increment(Number(data.mc_gross))

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda