I have a function that should return a list of documents data from a given collection.
function _getPrevActivity(){
let historyCollectionRef = firestore.collection("/users/RSgNDLPxT2aAERQutXEEyhHHJYk1/agreements/DkRdZ5kHi2g7MlBV3Kjq/test/test-something/records/15/history");
let value = [];
let wait;
historyCollectionRef.orderBy('timeStamp').onSnapshot(querSnap => {
querSnap.forEach(doc => {
value.push(doc.data())
console.log(value.length, " length")
})
console.log(value)
return value;
});
return value;
}
This functions is always returning []
and later executing the firestore query.
PS: I am new to Node env, there might be something wrong with how I wrote the function as well.