as the title suggests I'm trying to use FieldValue and FirestoreAdminClient as follow:
const client = new admin.firestore.v1.FirestoreAdminClient();
And in another function of my server:
await db.doc("stats/users").update({
total: admin.firestore.FieldValue.increment(1),
});
But when I run my function I get:
TypeError: Cannot read properties of undefined (reading 'FirestoreAdminClient')
I don't know what's happening and why. If you have any suggestion please share it
I have been searching for this for like a whole day and found the solution from one of the firebase NodeJS snippets repositories. I know it is not in typescript so just change the import accordingly.
// for the import part
const {getFirestore, FieldValue} = require("firebase-admin/firestore");
// also, getFirestore is another import I needed and you might not so change accordingly
// for the update
await admin
.firestore()
.collection("Posts").doc(docId).update({
postImages: FieldValue.arrayUnion(signedUrl),
}).then((_) => {
functions.logger.log("Updated the image link successfully");
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With