-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Labels
Description
Environment
- Operating System version: All
- Firebase SDK version: 6.0.0
- Firebase Product: Firestore
Problem
Thanks for adding the new admin.firestore.FieldValue.arrayUnion()
and admin.firestore.FieldValue.arrayRemove()
features. They're super handy! I think I found a bug in it though. When you try to add an item which contains admin.firestore.FieldValue.serverTimestamp()
via admin.firestore.FieldValue.arrayUnion()
, the timestamp is never set and the corresponding field is dropped.
Steps to reproduce:
- Run the repro below.
Expected result:
The database should look like this:
Actual result:
The database ends up looking like this:
If you switch the non-working admin.firestore.FieldValue.serverTimestamp()
with new Date()
, the expected result occurs.
Relevant Code:
return admin.firestore().doc('items/2').set({
someArray: admin.firestore.FieldValue.arrayUnion({
createdAt: admin.firestore.FieldValue.serverTimestamp(),
foo: 'bar',
}),
})
.then(() => console.log('Success!'))
.catch((error) => console.log('Error:', error));
Note that this also fails, resulting an an empty someArray
array:
return admin.firestore().doc('items/2').set({
someArray: admin.firestore.FieldValue.arrayUnion(
admin.firestore.FieldValue.serverTimestamp()
),
})
.then(() => console.log('Success!'))
.catch((error) => console.log('Error:', error));