Skip to content

Commit

Permalink
Add guard for contextParams in typesenseDocumentFromSnapshot()
Browse files Browse the repository at this point in the history
  • Loading branch information
jsasitorn committed Dec 18, 2024
1 parent e3fdd60 commit 0c3e305
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions functions/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,11 @@ exports.typesenseDocumentFromSnapshot = async (firestoreDocumentSnapshot, contex

typesenseDocument.id = firestoreDocumentSnapshot.id;

Object.entries(contextParams).forEach(([key, value]) => {
typesenseDocument[key] = value;
});
if (contextParams && Object.entries(contextParams).length) {
Object.entries(contextParams).forEach(([key, value]) => {
typesenseDocument[key] = value;
});
}

return typesenseDocument;
};
Expand Down

0 comments on commit 0c3e305

Please sign in to comment.