Closed
Description
[REQUIRED] Step 2: Describe your environment
- Operating System version: macOS v12.6
- Firebase SDK version: 11.2.0
- Firebase Product: Firestore
- Node.js version: v16.16.0
- NPM version: 8.11.0
[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.
await firestore.doc(`someCollection/someDocID`).set({
date_updated: currentDateTime,
date_updated_timestamp: currentDateTimeTimestamp,
operations: admin.firestore.FieldValue.arrayUnion({
type: operationType,
operation_at: currentDateTime
}),
...payload
}, { merge: true }).catch(e => {
console.error(e);
// throw error
});
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.
> operations: admin.firestore.FieldValue.arrayUnion({
> ^
>
> TypeError: Cannot read properties of undefined (reading 'arrayUnion')
Relevant Code:
// Initializing Firebase in CloudFunctions
const
functions = require("firebase-functions"),
admin = require('firebase-admin');
const IS_EMULATOR = ((typeof process.env.FUNCTIONS_EMULATOR === 'boolean' && process.env.FUNCTIONS_EMULATOR) || process.env.FUNCTIONS_EMULATOR === 'true');
admin.initializeApp();
let firestore = admin.firestore();
if (IS_EMULATOR) {
firestore.settings({
host: 'localhost',
port: '8081',
ssl: false
})
}
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 :)