I solved this thanks to someone on StackOverflow: stackoverflow.com/a/49593544/4186181
I'm not in love with solution, and it's weird there's not much information on this but I guess it's the cleanest one.
This solutions makes quite a bit of sense. Reminds me of Firestore's js library:
const transaction = db.runTransaction(async t => { const doc = await t.get(cityRef) var newPopulation = doc.data().population + 1 await t.update(cityRef, { population: newPopulation }) })
It's the same substitution of global db inside a callback to the transaction method on our specific db struct.
db
const whatAmI = async db => { const doc = await db.get(cityRef) var newPopulation = doc.data().population + 1 await db.update(cityRef, { population: newPopulation }) } const notATransaction = whatAmI(db) const aTransaction = db.runTransaction(whatAmI)
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I solved this thanks to someone on StackOverflow: stackoverflow.com/a/49593544/4186181
I'm not in love with solution, and it's weird there's not much information on this but I guess it's the cleanest one.
This solutions makes quite a bit of sense.
Reminds me of Firestore's js library:
It's the same substitution of global
db
inside a callback to the transaction method on our specificdb
struct.