-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Firestore] - FieldValue.arrayUnion broken on version 11.2.0 #1954
Comments
I found a few problems with this issue:
|
After looking at some other issues that other users were having with Firestore here in the repository and reading this comment from @lahirumaramba, it was enough minor modifications in the way to call the Firestore functions that the problem was solved. The big problem was the switch to modular SDK To resolve: 1) Initialize Firebase in Cloud Functions const
{ initializeApp } = require('firebase-admin/app'),
{ getFirestore } = require('firebase-admin/firestore');
const IS_EMULATOR = ((typeof process.env.FUNCTIONS_EMULATOR === 'boolean' && process.env.FUNCTIONS_EMULATOR) || process.env.FUNCTIONS_EMULATOR === 'true');
initializeApp();
let firestore = getFirestore();
if (IS_EMULATOR) {
firestore.settings({
host: 'localhost',
port: '8081',
ssl: false
})
} 2) And when using the Firestore with arrayUnion update function const
{ FieldValue } = require('firebase-admin/firestore');
await firestore.doc(`someCollection/someDocID`).set({
date_updated: currentDateTime,
date_updated_timestamp: currentDateTimeTimestamp,
operations: FieldValue.arrayUnion({
type: operationType,
operation_at: currentDateTime
}),
...payload
}, { merge: true }).catch(e => {
console.error(e);
// throw error
}); |
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
After updating firebase-admin from 10.3.0 to use the new COUNT() feature, I can no longer update a DOC with set() and FieldValue.arrayUnion, even though the property was in the Document previously.
Steps to reproduce:
In version 10.3.0 when I use the code below it works as expected.
In version 11.2.0 when I use the same code above, it returns an error, in the console and does not update the Document.
Relevant Code:
I don't know if, between versions 10.3.0 and 11.2.0, the way to call the
arrayUnion({})
function changed or if I'm doing something wrong, but since nothing was changed in the code, only the version, I understand that maybe the problem be on the new version, any input is welcome :)The text was updated successfully, but these errors were encountered: