Advertisement
Guest User

Untitled

a guest
May 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. let userRef2 = firebase.firestore().collection("users").doc(participantID);
  2. const result2 = await firebase.firestore().collection("recommendedVideo").where("user", "==", userRef2).get();
  3. alert("3 "+result2.size);
  4.  
  5. await Promise.all(result2.map(async doc2 => {
  6. alert(doc2);
  7.  
  8. //3 - Get video ref to compate to Array
  9. const videoFef = doc2.data().video.id;
  10. alert("videoFef "+videoFef);
  11. const doc3 = await firebase.firestore().collection("videos").doc(videoFef).get();
  12. if (!doc3.exists) {
  13. alert("Não exisste doc videos");
  14. return;
  15. }
  16.  
  17. var sequence = doc3.data().sequenceNumberID;
  18. for (var i = 0; i < newRec.length; i++) {
  19. alert("5 ");
  20. if (String(sequence) !== String(newRec[i])) return;
  21. var index = newRec.indexOf(newRec[i]);
  22. if (index > -1) newRec.splice(index, 1);
  23. }
  24.  
  25. })).catch(function (error) {
  26. alert(error);
  27. })
  28. // end of Promise.all
  29. insertData(newRec);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement