Closed asentris closed 3 years ago
Currently this is not possible with the approach I have taken. I am thinking through an approach that will clean up null attributes. Will update when I have a solution.
How often are you setting attributes to null? Can you send me examples so I can see if there are alternative solutions I can think through?
The attributes aren't set to null very often. Example: a document may have an attribute that was mistakenly given a value (by a user), so it is later corrected to null.
https://discourse.algolia.com/t/deleting-attributes-in-partial-updates/10154 I think we might be better off updating the objects altogether instead of partially updating. It doesn't have a difference in cost and will solve this issue. Deleting objects alltogether isn't solved by just swapping partialUpdate to save though
this issue is a duplicate of #60
@Haroenv The partialUpdate was used to manage race conditions that could occur from the cold start up of the Cloud functions. Before this approach, I had an extra call to the Firestore db to sync up the records after then Cloud Function was warmed up, but this would be a Firestore cost.
I am currently considering looping through the payload for null values. If I encounter any fields with null values, i will use the saveObject method. However, I will have to make a call to Firestore db to refresh the data just in case if the data has changed.
@Haroenv The partialUpdate was used to manage race conditions that could occur from the cold start up of the Cloud functions. Before this approach, I had an extra call to the Firestore db to sync up the records after then Cloud Function was warmed up, but this would be a Firestore cost.
I am currently considering looping through the payload for null values. If I encounter any fields with null values, i will use the saveObject method. However, I will have to make a call to Firestore db to refresh the data just in case if the data has changed.
Ok but what if someone uses firebase.firestore.FieldValue.delete() to remove the field?
When I update a field value within a Firestore document to null, the extension executes, but does not actually update the value in the Algolia index. I would assume the Algolia value would be deleted from the index, as null values are not transferred from Firestore to Algolia.