videos.ts

import { VIDEOS } from '../../utility/constants/values';

export async function getVideos(context) {
  const { firestore, envmt, activeDbId } = context;
  const snapshot = await firestore.collection(`${envmt}-${VIDEOS}-${activeDbId}`).get();
  return snapshot.docs.map((doc) => doc.data());
}

export async function getVideo(context, videoId) {
  const { firestore, envmt, activeDbId } = context;
  const snapshot = await firestore.collection(`${envmt}-${VIDEOS}-${activeDbId}`).where('videoId', '==', videoId).get();

  let video;

  snapshot.forEach((document) => {
    video = { ...document.data() };
  });

  return video;
}