Firestore Cloud Function - Value of external variable not recognized in .then()
问题 I am new to Firestore cloud functions, and trying to run a simple function that triggers onWrite() in one collection and based on that, updates value in different one. I am hitting roadblock where value of variable (const array actually), is not recognized inside the ...get().then(snapshot) => {} method. As I understand the outer variable's scope should be inside as well, shouldn't it? What am I doing wrong? Research on this topic led me to concept of Promises, and I tried creating promise